我正在阅读 xmpp/extensions/xep-0313.html 向Ejabberd查询某个用户存档的邮件。
I'm reading xmpp/extensions/xep-0313.html to query Ejabberd for messages archived with a certain user.
这是我要发送的xml:
This is the xml that I'm sending:
<iq type='get' id='get_archive_user1'> <query xmlns='urn:xmpp:mam:tmp'> <with>user1@localhost</with> <set xmlns='jabber/protocol/rsm'> <max>20</max> </set> </query> </iq>我正确接收了前20条消息。要再次请求,我要添加标签:
I'm receiving the first 20 messages correctly. To request again I'm adding the tag:
<after>(id in element "Last" from last request)</after>,这也可以正常工作。我需要的是接收最后20条消息,而不是前20条消息。我该如何实现?
and this also work fine. What I need is to receive the last 20 messages, not the first 20 messages. How can I achieve this?
推荐答案XEP-0313邮件存档管理依靠 XEP-0059结果集管理进行分页。
RSM规范说明了如何获取广告中的最后一页结果集:
请求实体可以通过在其请求中包括一个空的< before /> 元素,以及要返回的最大项目数。
The requesting entity MAY ask for the last page in a result set by including in its request an empty <before/> element, and the maximum number of items to return.
这意味着您需要在结果集查询中添加一个空的< before /> 元素。
It means you need to add an empty <before/> element in your result set query.
这里是一个基于XEP-0313版本0.4的示例,该示例如何获取与给定用户的对话中的最后20条消息。查询限制由参数 max 定义(它定义了页面的大小)。
Here is an example based on XEP-0313 version 0.4 on how to get the last 20 messages in a conversation with a given user. The query limit is defined by the parameter max (it defined the size of the pages).
<iq type='set' id='q29302'> <query xmlns='urn:xmpp:mam:0'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:mam:0</value> </field> <field var='with'> <value>juliet@capulet.lit</value> </field> </x> <set xmlns='jabber/protocol/rsm'> <max>20</max> <before/> </set> </query> </iq>更多推荐
XMPP查询归档的最新消息
发布评论