Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0060.py @ 2718:bb6adaa580ee
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)
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 10 Dec 2018 20:34:45 +0100 |
parents | 6555e9835ff8 |
children | f4070693814a |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py Mon Dec 10 20:34:45 2018 +0100 +++ b/sat/plugins/plugin_xep_0060.py Mon Dec 10 20:34:45 2018 +0100 @@ -475,18 +475,12 @@ 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 @@ @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 @@ 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"])