In some cases, it is useful for the order of items in a page to be reversed when paging backwards through a result set. These cases are typically when the result page is returned as a series of response stanzas by the wrapper protocol instead of as a single result stanza.
Requesting reverse order for a result set page is done by including a <reversed />
element in the page request.
-
If the wrapping protocol batches the items of a page into a single response stanza, the requesting entity SHOULD NOT include a
<reversed />
element, but the responding entity MAY reverse the order of the items if requested. -
If the wrapping protocol returns the items of a page as a series of response stanzas, the requesting entity MAY include a
<reversed />
element and the responding entity SHOULD reverse the order in which the page's items are returned.
If the responding entity reverses the order of items in a page, it MUST include
a <reversed />
element in the page result summary.
NOTE: the semantics of the <first />
and <last />
elements are unaffected by
requesting items in reversed order.
<iq type='get' id='q29302'>
<query xmlns='urn:xmpp:mam:tmp'>
<end>2010-08-07T00:00:00Z</start>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>10</max>
<before />
<reversed />
</set>
</query>
</iq>
<message id='aeb213' to='[email protected]/chamber'>
<result xmlns='urn:xmpp:mam:tmp' id='5d398-28273-f7382'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:09:32Z'/>
<message to='[email protected]/orchard'
from='[email protected]/balcony'
type='chat' id='8a54s'>
<body>What man art thou that thus bescreen'd in night so stumblest on my counsel?</body>
</message>
</forwarded>
</result>
</message>
[ 8 more response stanzas ]
<message id='aeb222' to='[email protected]/chamber'>
<result xmlns='urn:xmpp:mam:tmp' id='28482-98726-73623'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>
<message to='[email protected]/balcony'
from='[email protected]/orchard'
type='chat'>
<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>
</message>
</forwarded>
</result>
</message>
<iq type='result' id='q29302'>
<query xmlns='urn:xmpp:mam:tmp'>
<set xmlns='http://jabber.org/protocol/rsm'>
<first index='42'>28482-98726-73623</first>
<last>5d398-28273-f7382</last>
<count>10</count>
<reversed />
</set>
</iq>
- Would it be worth adding a new disco feature for reversal support, like http://jabber.org/protocol/rsm#reverse?
- If no to the disco feature, should the first response stanza include a flag indicating that the page is reversed?
This would be awesome and save a lot of bookkeeping on the client, and (I think) relatively easily implemented on the server, particularly using SQL.
It would be particularly useful for MAM. I don't think any of the common servers implement anything like this, right?
I've only recently started working with XMPP, but looking at the version history of XEP 0059, it looks like there may have been something proposed back in 2006 that was similar to this, called "reverse order sets": https://xmpp.org/extensions/xep-0059.html#appendix-revs I can't find any more information on the specifics.