Mercurial > libervia-backend
changeset 2758:f4070693814a
plugin XEP-0060: fixed MAM return value on getItems():
callback to generate metadata was using wrong items in return argument.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 06 Jan 2019 17:33:53 +0100 (2019-01-06) |
parents | 1f612547fb2e |
children | 607cfc79e40f |
files | sat/plugins/plugin_xep_0060.py |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py Sat Jan 05 14:15:11 2019 +0100 +++ b/sat/plugins/plugin_xep_0060.py Sun Jan 06 17:33:53 2019 +0100 @@ -516,7 +516,8 @@ @param service (JID, None): pubsub service. @param node (str): node id. @param max_items (int): optional limit on the number of retrieved items. - @param item_ids (list[str]): identifiers of the items to be retrieved (can't be used with rsm_request). + @param item_ids (list[str]): identifiers of the items to be retrieved (can't be + used with rsm_request). @param sub_id (str): optional subscription identifier. @param rsm_request (rsm.RSMRequest): RSM request data @return: a deferred couple (list[dict], dict) containing: @@ -538,6 +539,8 @@ d = client.pubsub_client.items( service, node, max_items, item_ids, sub_id, None, rsm_request ) + # we have no MAM data here, so we add None + d.addCallback(lambda data: data + (None,)) else: # if mam is requested, we have to do a totally different query if self._mam is None: @@ -560,8 +563,6 @@ 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"]) @@ -586,7 +587,8 @@ d.addCallback(doSubscribe) def addMetadata(result): - items, rsm_response = result + # TODO: handle the third argument (mam_response) + items, rsm_response, mam_response = result service_jid = service if service else client.jid.userhostJID() metadata = { "service": service_jid, @@ -596,10 +598,13 @@ if rsm_request is not None and rsm_response is not None: metadata.update( { - "rsm_{}".format(key): value + u"rsm_" + key: value for key, value in rsm_response.toDict().iteritems() } ) + if mam_response is not None: + for key, value in mam_response.iteritems(): + metadata[u"mam_" + key] = value return (items, metadata) d.addCallback(addMetadata)