comparison src/plugins/plugin_xep_0060.py @ 1903:29564cec913f

plugin XEP-0060: service, node and uri are added to metadata when doing a getItems
author Goffi <goffi@goffi.org>
date Wed, 09 Mar 2016 16:59:29 +0100
parents fc6eeacf31bc
children 614f3abb2c69
comparison
equal deleted inserted replaced
1902:085f29c20f7e 1903:29564cec913f
279 @param profile_key (unicode): %(doc_profile_key)s 279 @param profile_key (unicode): %(doc_profile_key)s
280 @return: a deferred couple (list[dict], dict) containing: 280 @return: a deferred couple (list[dict], dict) containing:
281 - list of items 281 - list of items
282 - metadata with the following keys: 282 - metadata with the following keys:
283 - rsm_first, rsm_last, rsm_count, rsm_index: first, last, count and index value of RSMResponse 283 - rsm_first, rsm_last, rsm_count, rsm_index: first, last, count and index value of RSMResponse
284 - service, node: service and node used
284 """ 285 """
285 if rsm_request and item_ids: 286 if rsm_request and item_ids:
286 raise ValueError(u"items_id can't be used with rsm") 287 raise ValueError(u"items_id can't be used with rsm")
287 if extra is None: 288 if extra is None:
288 extra = {} 289 extra = {}
326 if subscribe: 327 if subscribe:
327 d.addCallback(doSubscribe) 328 d.addCallback(doSubscribe)
328 329
329 def addMetadata(result): 330 def addMetadata(result):
330 items, rsm_response = result 331 items, rsm_response = result
332 metadata = {'service': service or client.jid.host,
333 'node': node,
334 'uri': self.getNodeURI(service, node),
335 }
331 if rsm_request is not None and rsm_response is not None: 336 if rsm_request is not None and rsm_response is not None:
332 metadata = {'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()} 337 metadata.update({'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()})
333 else:
334 metadata = {}
335 return (items, metadata) 338 return (items, metadata)
336 339
337 d.addCallback(addMetadata) 340 d.addCallback(addMetadata)
338 return d 341 return d
339 342