plugin XEP-0313, XEP-0045: loop MAM requests until whole archive is retrieved:

- plugin xep-0313: new serialise method
-                : getArchives now returns an extra mam_response dict with "complete" and "stable" status
-                : MAMGet now return a new metadata dict before profile (with serialised RSM and MAM response)
This commit is contained in:
Goffi 2018-12-10 20:34:45 +01:00
commit c77bc72490

View file

@ -475,18 +475,12 @@ class XEP_0060(object):
def _unwrapMAMMessage(self, message_elt):
try:
item_elt = (
message_elt.elements(mam.NS_MAM, "result")
.next()
.elements(C.NS_FORWARD, "forwarded")
.next()
.elements(C.NS_CLIENT, "message")
.next()
.elements("http://jabber.org/protocol/pubsub#event", "event")
.next()
.elements("http://jabber.org/protocol/pubsub#event", "items")
.next()
.elements("http://jabber.org/protocol/pubsub#event", "item")
.next()
message_elt.elements(mam.NS_MAM, "result").next()
.elements(C.NS_FORWARD, "forwarded").next()
.elements(C.NS_CLIENT, "message").next()
.elements("http://jabber.org/protocol/pubsub#event", "event").next()
.elements("http://jabber.org/protocol/pubsub#event", "items").next()
.elements("http://jabber.org/protocol/pubsub#event", "item").next()
)
except StopIteration:
raise exceptions.DataError(u"Can't find Item in MAM message element")
@ -528,7 +522,8 @@ class XEP_0060(object):
@return: a deferred couple (list[dict], dict) containing:
- list of items
- metadata with the following keys:
- rsm_first, rsm_last, rsm_count, rsm_index: first, last, count and index value of RSMResponse
- rsm_first, rsm_last, rsm_count, rsm_index: first, last, count and index
value of RSMResponse
- service, node: service and node used
"""
if item_ids and max_items is not None:
@ -565,6 +560,8 @@ class XEP_0060(object):
u"Conflict between RSM request and MAM's RSM request"
)
d = self._mam.getArchives(client, mam_query, service, self._unwrapMAMMessage)
# FIXME: we only keep items for now, but RSM and MAM metadata should be used
d.addCallback(lambda archives: archives[0])
try:
subscribe = C.bool(extra["subscribe"])