comparison sat/plugins/plugin_xep_0277.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 d830c11eeef3
comparison
equal deleted inserted replaced
3585:31628770a15a 3586:5f65f4e9f8cb
116 async_=True, 116 async_=True,
117 ) 117 )
118 host.bridge.addMethod( 118 host.bridge.addMethod(
119 "mbGet", 119 "mbGet",
120 ".plugin", 120 ".plugin",
121 in_sign="ssiasa{ss}s", 121 in_sign="ssiasss",
122 out_sign="s", 122 out_sign="s",
123 method=self._mbGet, 123 method=self._mbGet,
124 async_=True, 124 async_=True,
125 ) 125 )
126 host.bridge.addMethod( 126 host.bridge.addMethod(
929 def _mbGetSerialise(self, data): 929 def _mbGetSerialise(self, data):
930 items, metadata = data 930 items, metadata = data
931 metadata['items'] = items 931 metadata['items'] = items
932 return data_format.serialise(metadata) 932 return data_format.serialise(metadata)
933 933
934 def _mbGet(self, service="", node="", max_items=10, item_ids=None, extra_dict=None, 934 def _mbGet(self, service="", node="", max_items=10, item_ids=None, extra="",
935 profile_key=C.PROF_KEY_NONE): 935 profile_key=C.PROF_KEY_NONE):
936 """ 936 """
937 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 937 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
938 @param item_ids (list[unicode]): list of item IDs 938 @param item_ids (list[unicode]): list of item IDs
939 """ 939 """
940 client = self.host.getClient(profile_key) 940 client = self.host.getClient(profile_key)
941 service = jid.JID(service) if service else None 941 service = jid.JID(service) if service else None
942 max_items = None if max_items == C.NO_LIMIT else max_items 942 max_items = None if max_items == C.NO_LIMIT else max_items
943 extra = self._p.parseExtra(extra_dict) 943 extra = self._p.parseExtra(data_format.deserialise(extra))
944 d = defer.ensureDeferred( 944 d = defer.ensureDeferred(
945 self.mbGet(client, service, node or None, max_items, item_ids, 945 self.mbGet(client, service, node or None, max_items, item_ids,
946 extra.rsm_request, extra.extra) 946 extra.rsm_request, extra.extra)
947 ) 947 )
948 d.addCallback(self._mbGetSerialise) 948 d.addCallback(self._mbGetSerialise)