comparison sat/plugins/plugin_xep_0060.py @ 3312:77177b13ff54

plugin XEP-0060: serialise psItemsGet result with data_format
author Goffi <goffi@goffi.org>
date Fri, 17 Jul 2020 12:57:23 +0200
parents 384283adcce1
children 23af257ae780
comparison
equal deleted inserted replaced
3311:29f8122f00f3 3312:77177b13ff54
188 ) 188 )
189 host.bridge.addMethod( 189 host.bridge.addMethod(
190 "psItemsGet", 190 "psItemsGet",
191 ".plugin", 191 ".plugin",
192 in_sign="ssiassa{ss}s", 192 in_sign="ssiassa{ss}s",
193 out_sign="(asa{ss})", 193 out_sign="s",
194 method=self._getItems, 194 method=self._getItems,
195 async_=True, 195 async_=True,
196 ) 196 )
197 host.bridge.addMethod( 197 host.bridge.addMethod(
198 "psItemSend", 198 "psItemSend",
597 )) 597 ))
598 except StopIteration: 598 except StopIteration:
599 raise exceptions.DataError("Can't find Item in MAM message element") 599 raise exceptions.DataError("Can't find Item in MAM message element")
600 return item_elt 600 return item_elt
601 601
602 def serialiseItems(self, items_data):
603 items, metadata = items_data
604 metadata['items'] = items
605 return data_format.serialise(metadata)
606
602 def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None, 607 def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
603 extra_dict=None, profile_key=C.PROF_KEY_NONE): 608 extra_dict=None, profile_key=C.PROF_KEY_NONE):
604 """Get items from pubsub node 609 """Get items from pubsub node
605 610
606 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 611 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
618 sub_id or None, 623 sub_id or None,
619 extra.rsm_request, 624 extra.rsm_request,
620 extra.extra, 625 extra.extra,
621 ) 626 )
622 d.addCallback(self.transItemsData) 627 d.addCallback(self.transItemsData)
628 d.addCallback(self.serialiseItems)
623 return d 629 return d
624 630
625 def getItems(self, client, service, node, max_items=None, item_ids=None, sub_id=None, 631 def getItems(self, client, service, node, max_items=None, item_ids=None, sub_id=None,
626 rsm_request=None, extra=None): 632 rsm_request=None, extra=None):
627 """Retrieve pubsub items from a node. 633 """Retrieve pubsub items from a node.