plugin XEP-0060: fixed MAM return value on getItems():
callback to generate metadata was using wrong items in return argument.
This commit is contained in:
parent
70253cd205
commit
9dd628d1ed
1 changed files with 10 additions and 5 deletions
|
|
@ -516,7 +516,8 @@ class XEP_0060(object):
|
|||
@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 @@ class XEP_0060(object):
|
|||
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 @@ 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"])
|
||||
|
|
@ -586,7 +587,8 @@ class XEP_0060(object):
|
|||
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 @@ class XEP_0060(object):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue