comparison sat/plugins/plugin_xep_0060.py @ 3586:5f65f4e9f8cb

plugin XEP-0060: getItems extra is now serialised dict
author Goffi <goffi@goffi.org>
date Wed, 28 Jul 2021 23:01:15 +0200
parents edc79cefe968
children 2715da5b2aa7
comparison
equal deleted inserted replaced
3585:31628770a15a 3586:5f65f4e9f8cb
195 async_=True, 195 async_=True,
196 ) 196 )
197 host.bridge.addMethod( 197 host.bridge.addMethod(
198 "psItemsGet", 198 "psItemsGet",
199 ".plugin", 199 ".plugin",
200 in_sign="ssiassa{ss}s", 200 in_sign="ssiassss",
201 out_sign="s", 201 out_sign="s",
202 method=self._getItems, 202 method=self._getItems,
203 async_=True, 203 async_=True,
204 ) 204 )
205 host.bridge.addMethod( 205 host.bridge.addMethod(
282 async_=True, 282 async_=True,
283 ) 283 )
284 host.bridge.addMethod( 284 host.bridge.addMethod(
285 "psGetFromMany", 285 "psGetFromMany",
286 ".plugin", 286 ".plugin",
287 in_sign="a(ss)ia{ss}s", 287 in_sign="a(ss)iss",
288 out_sign="s", 288 out_sign="s",
289 method=self._getFromMany, 289 method=self._getFromMany,
290 ) 290 )
291 host.bridge.addMethod( 291 host.bridge.addMethod(
292 "psGetFromManyRTResult", 292 "psGetFromManyRTResult",
611 items, metadata = items_data 611 items, metadata = items_data
612 metadata['items'] = items 612 metadata['items'] = items
613 return data_format.serialise(metadata) 613 return data_format.serialise(metadata)
614 614
615 def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None, 615 def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
616 extra_dict=None, profile_key=C.PROF_KEY_NONE): 616 extra="", profile_key=C.PROF_KEY_NONE):
617 """Get items from pubsub node 617 """Get items from pubsub node
618 618
619 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 619 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
620 """ 620 """
621 client = self.host.getClient(profile_key) 621 client = self.host.getClient(profile_key)
622 service = jid.JID(service) if service else None 622 service = jid.JID(service) if service else None
623 max_items = None if max_items == C.NO_LIMIT else max_items 623 max_items = None if max_items == C.NO_LIMIT else max_items
624 extra = self.parseExtra(extra_dict) 624 extra = self.parseExtra(data_format.deserialise(extra))
625 d = defer.ensureDeferred(self.getItems( 625 d = defer.ensureDeferred(self.getItems(
626 client, 626 client,
627 service, 627 service,
628 node or None, 628 node or None,
629 max_items or None, 629 max_items or None,
1437 ) 1437 )
1438 ) 1438 )
1439 return d 1439 return d
1440 1440
1441 def _getFromMany( 1441 def _getFromMany(
1442 self, node_data, max_item=10, extra_dict=None, profile_key=C.PROF_KEY_NONE 1442 self, node_data, max_item=10, extra="", profile_key=C.PROF_KEY_NONE
1443 ): 1443 ):
1444 """ 1444 """
1445 @param max_item(int): maximum number of item to get, C.NO_LIMIT for no limit 1445 @param max_item(int): maximum number of item to get, C.NO_LIMIT for no limit
1446 """ 1446 """
1447 max_item = None if max_item == C.NO_LIMIT else max_item 1447 max_item = None if max_item == C.NO_LIMIT else max_item
1448 extra = self.parseExtra(extra_dict) 1448 extra = self.parseExtra(data_format.deserialise(extra))
1449 return self.getFromMany( 1449 return self.getFromMany(
1450 [(jid.JID(service), str(node)) for service, node in node_data], 1450 [(jid.JID(service), str(node)) for service, node in node_data],
1451 max_item, 1451 max_item,
1452 extra.rsm_request, 1452 extra.rsm_request,
1453 extra.extra, 1453 extra.extra,