Mercurial > libervia-backend
changeset 2185:dd53d7a3219a
plugin XEP-0060: added psGet bridge method
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Mar 2017 23:28:04 +0100 |
parents | e0f91efa404a |
children | 9061c7247964 |
files | src/plugins/plugin_misc_invitations.py src/plugins/plugin_xep_0060.py |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_invitations.py Sun Mar 12 19:35:36 2017 +0100 +++ b/src/plugins/plugin_misc_invitations.py Sun Mar 12 23:28:04 2017 +0100 @@ -62,7 +62,6 @@ class InvitationsPlugin(object): - # TODO: plugin unload def __init__(self, host): log.info(_(u"plugin Invitations initialization"))
--- a/src/plugins/plugin_xep_0060.py Sun Mar 12 19:35:36 2017 +0100 +++ b/src/plugins/plugin_xep_0060.py Sun Mar 12 23:28:04 2017 +0100 @@ -85,6 +85,7 @@ self._mam = host.plugins.get('XEP-0313') self._node_cb = {} # dictionnary of callbacks for node (key: node, value: list of callbacks) self.rt_sessions = sat_defer.RTDeferredSessions() + host.bridge.addMethod("psGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True) host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True) host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True) host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True) @@ -266,6 +267,18 @@ raise exceptions.DataError(u"Can't find Item in MAM message element") return item_elt + def _getItems(self, service='', node='', max_items=10, item_ids=None, sub_id=None, extra_dict=None, 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 + """ + 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) + d = self.getItems(service, node or None, max_items or None, item_ids, sub_id or None, extra.rsm_request, extra.extra, profile_key) + d.addCallback(self.serItemsData) + return d + def getItems(self, service, node, max_items=None, item_ids=None, sub_id=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE): """Retrieve pubsub items from a node.