plugin XEP-0060: getItems extra is now serialised dict
This commit is contained in:
parent
fcbbc2aeed
commit
f2a06bbcbf
5 changed files with 32 additions and 31 deletions
|
|
@ -219,7 +219,7 @@ class PubsubLists:
|
|||
host.bridge.addMethod(
|
||||
"listGet",
|
||||
".plugin",
|
||||
in_sign="ssiassa{ss}s",
|
||||
in_sign="ssiassss",
|
||||
out_sign="s",
|
||||
method=lambda service, node, max_items, items_ids, sub_id, extra, profile_key:
|
||||
self._s._get(
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class MergeRequests(object):
|
|||
self._handlers_list = [] # handlers sorted by priority
|
||||
self._type_handlers = {} # data type => handler map
|
||||
host.bridge.addMethod("mergeRequestsGet", ".plugin",
|
||||
in_sign='ssiassa{ss}s', out_sign='s',
|
||||
in_sign='ssiassss', out_sign='s',
|
||||
method=self._get,
|
||||
async_=True
|
||||
)
|
||||
|
|
@ -149,11 +149,10 @@ class MergeRequests(object):
|
|||
})
|
||||
|
||||
def _get(self, service='', node='', max_items=10, item_ids=None, sub_id=None,
|
||||
extra_dict=None, profile_key=C.PROF_KEY_NONE):
|
||||
if extra_dict and 'parse' in extra_dict:
|
||||
extra_dict['parse'] = C.bool(extra_dict['parse'])
|
||||
extra="", profile_key=C.PROF_KEY_NONE):
|
||||
extra = data_format.deserialise(extra)
|
||||
client, service, node, max_items, extra, sub_id = self._s.prepareBridgeGet(
|
||||
service, node, max_items, sub_id, extra_dict, profile_key)
|
||||
service, node, max_items, sub_id, extra, profile_key)
|
||||
d = self.get(client, service, node or None, max_items, item_ids, sub_id or None,
|
||||
extra.rsm_request, extra.extra)
|
||||
d.addCallback(self.serialise)
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class XEP_0060(object):
|
|||
host.bridge.addMethod(
|
||||
"psItemsGet",
|
||||
".plugin",
|
||||
in_sign="ssiassa{ss}s",
|
||||
in_sign="ssiassss",
|
||||
out_sign="s",
|
||||
method=self._getItems,
|
||||
async_=True,
|
||||
|
|
@ -284,7 +284,7 @@ class XEP_0060(object):
|
|||
host.bridge.addMethod(
|
||||
"psGetFromMany",
|
||||
".plugin",
|
||||
in_sign="a(ss)ia{ss}s",
|
||||
in_sign="a(ss)iss",
|
||||
out_sign="s",
|
||||
method=self._getFromMany,
|
||||
)
|
||||
|
|
@ -613,7 +613,7 @@ class XEP_0060(object):
|
|||
return data_format.serialise(metadata)
|
||||
|
||||
def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
|
||||
extra_dict=None, profile_key=C.PROF_KEY_NONE):
|
||||
extra="", profile_key=C.PROF_KEY_NONE):
|
||||
"""Get items from pubsub node
|
||||
|
||||
@param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
|
||||
|
|
@ -621,7 +621,7 @@ class XEP_0060(object):
|
|||
client = self.host.getClient(profile_key)
|
||||
service = jid.JID(service) if service else None
|
||||
max_items = None if max_items == C.NO_LIMIT else max_items
|
||||
extra = self.parseExtra(extra_dict)
|
||||
extra = self.parseExtra(data_format.deserialise(extra))
|
||||
d = defer.ensureDeferred(self.getItems(
|
||||
client,
|
||||
service,
|
||||
|
|
@ -1439,13 +1439,13 @@ class XEP_0060(object):
|
|||
return d
|
||||
|
||||
def _getFromMany(
|
||||
self, node_data, max_item=10, extra_dict=None, profile_key=C.PROF_KEY_NONE
|
||||
self, node_data, max_item=10, extra="", profile_key=C.PROF_KEY_NONE
|
||||
):
|
||||
"""
|
||||
@param max_item(int): maximum number of item to get, C.NO_LIMIT for no limit
|
||||
"""
|
||||
max_item = None if max_item == C.NO_LIMIT else max_item
|
||||
extra = self.parseExtra(extra_dict)
|
||||
extra = self.parseExtra(data_format.deserialise(extra))
|
||||
return self.getFromMany(
|
||||
[(jid.JID(service), str(node)) for service, node in node_data],
|
||||
max_item,
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class XEP_0277(object):
|
|||
host.bridge.addMethod(
|
||||
"mbGet",
|
||||
".plugin",
|
||||
in_sign="ssiasa{ss}s",
|
||||
in_sign="ssiasss",
|
||||
out_sign="s",
|
||||
method=self._mbGet,
|
||||
async_=True,
|
||||
|
|
@ -931,7 +931,7 @@ class XEP_0277(object):
|
|||
metadata['items'] = items
|
||||
return data_format.serialise(metadata)
|
||||
|
||||
def _mbGet(self, service="", node="", max_items=10, item_ids=None, extra_dict=None,
|
||||
def _mbGet(self, service="", node="", max_items=10, item_ids=None, extra="",
|
||||
profile_key=C.PROF_KEY_NONE):
|
||||
"""
|
||||
@param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
|
||||
|
|
@ -940,7 +940,7 @@ class XEP_0277(object):
|
|||
client = self.host.getClient(profile_key)
|
||||
service = jid.JID(service) if service else None
|
||||
max_items = None if max_items == C.NO_LIMIT else max_items
|
||||
extra = self._p.parseExtra(extra_dict)
|
||||
extra = self._p.parseExtra(data_format.deserialise(extra))
|
||||
d = defer.ensureDeferred(
|
||||
self.mbGet(client, service, node or None, max_items, item_ids,
|
||||
extra.rsm_request, extra.extra)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class PubsubSchema(object):
|
|||
host.bridge.addMethod(
|
||||
"psItemsFormGet",
|
||||
".plugin",
|
||||
in_sign="ssssiassa{ss}s",
|
||||
in_sign="ssssiassss",
|
||||
out_sign="(asa{ss})",
|
||||
method=self._getDataFormItems,
|
||||
async_=True,
|
||||
|
|
@ -302,7 +302,7 @@ class PubsubSchema(object):
|
|||
return xml_tools.dataForm2dataDict(schema_form)
|
||||
|
||||
def _getDataFormItems(self, form_ns="", service="", node="", schema="", max_items=10,
|
||||
item_ids=None, sub_id=None, extra_dict=None,
|
||||
item_ids=None, sub_id=None, extra="",
|
||||
profile_key=C.PROF_KEY_NONE):
|
||||
client = self.host.getClient(profile_key)
|
||||
service = jid.JID(service) if service else None
|
||||
|
|
@ -313,7 +313,7 @@ class PubsubSchema(object):
|
|||
else:
|
||||
schema = None
|
||||
max_items = None if max_items == C.NO_LIMIT else max_items
|
||||
extra = self._p.parseExtra(extra_dict)
|
||||
extra = self._p.parseExtra(data_format.deserialise(extra))
|
||||
d = defer.ensureDeferred(
|
||||
self.getDataFormItems(
|
||||
client,
|
||||
|
|
@ -553,7 +553,7 @@ class PubsubSchema(object):
|
|||
|
||||
## Helper methods ##
|
||||
|
||||
def prepareBridgeGet(self, service, node, max_items, sub_id, extra_dict, profile_key):
|
||||
def prepareBridgeGet(self, service, node, max_items, sub_id, extra, profile_key):
|
||||
"""Parse arguments received from bridge *Get methods and return higher level data
|
||||
|
||||
@return (tuple): (client, service, node, max_items, extra, sub_id) usable for
|
||||
|
|
@ -566,12 +566,12 @@ class PubsubSchema(object):
|
|||
max_items = None if max_items == C.NO_LIMIT else max_items
|
||||
if not sub_id:
|
||||
sub_id = None
|
||||
extra = self._p.parseExtra(extra_dict)
|
||||
extra = self._p.parseExtra(extra)
|
||||
|
||||
return client, service, node, max_items, extra, sub_id
|
||||
|
||||
def _get(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
|
||||
extra=None, default_node=None, form_ns=None, filters=None,
|
||||
extra="", default_node=None, form_ns=None, filters=None,
|
||||
profile_key=C.PROF_KEY_NONE):
|
||||
"""Bridge method to retrieve data from node with schema
|
||||
|
||||
|
|
@ -583,8 +583,7 @@ class PubsubSchema(object):
|
|||
"""
|
||||
if filters is None:
|
||||
filters = {}
|
||||
if extra is None:
|
||||
extra = {}
|
||||
extra = data_format.deserialise(extra)
|
||||
# XXX: Q&D way to get list for labels when displaying them, but text when we
|
||||
# have to modify them
|
||||
if C.bool(extra.get("labels_as_list", C.BOOL_FALSE)):
|
||||
|
|
|
|||
Loading…
Reference in a new issue