Mercurial > libervia-backend
changeset 2305:972e33507609
plugin XEP-0060: addManagedNode callbacks now use client syntax instead of profile
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 Jul 2017 15:04:43 +0200 |
parents | 666ad9de044c |
children | 07deebea71f3 |
files | src/core/constants.py src/plugins/plugin_xep_0060.py src/plugins/plugin_xep_0163.py src/plugins/plugin_xep_0277.py |
diffstat | 4 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/constants.py Wed Jul 05 15:02:52 2017 +0200 +++ b/src/core/constants.py Wed Jul 05 15:04:43 2017 +0200 @@ -217,7 +217,7 @@ # PubSub PS_PUBLISH = "publish" PS_RETRACT = "retract" # used for items - PS_DELETE = "delete" #used for nodes + PS_DELETE = "delete" # used for nodes PS_ITEM = "item" PS_ITEMS = "items" # Can contain publish and retract items PS_EVENTS = (PS_ITEMS, PS_DELETE)
--- a/src/plugins/plugin_xep_0060.py Wed Jul 05 15:02:52 2017 +0200 +++ b/src/plugins/plugin_xep_0060.py Wed Jul 05 15:04:43 2017 +0200 @@ -188,9 +188,9 @@ @param node(unicode): node to monitor all node *prefixed* with this one will be triggered @param **kwargs: method(s) to call when the node is found - the methode must be named after PubSub constants in lower case + the method must be named after PubSub constants in lower case and suffixed with "_cb" - e.g.: "publish_cb" for C.PS_PUBLISH, "delete_cb" for C.PS_DELETE + e.g.: "items_cb" for C.PS_ITEMS, "delete_cb" for C.PS_DELETE """ assert node is not None assert kwargs @@ -792,12 +792,12 @@ def itemsReceived(self, event): log.debug(u"Pubsub items received") for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_ITEMS): - callback(event, self.parent.profile) + callback(self.parent, event) def deleteReceived(self, event): log.debug((u"Publish node deleted")) for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_DELETE): - callback(event, self.parent.profile) + callback(self.parent, event) def subscriptions(self, service, nodeIdentifier, sender=None): """Return the list of subscriptions to the given service and node.
--- a/src/plugins/plugin_xep_0163.py Wed Jul 05 15:02:52 2017 +0200 +++ b/src/plugins/plugin_xep_0163.py Wed Jul 05 15:04:43 2017 +0200 @@ -78,16 +78,15 @@ self.pep_events.add(node) if notify: self.pep_events.add(node + "+notify") - def filterPEPEvent(itemsEvent, profile): + def filterPEPEvent(client, itemsEvent): """Ignore messages which are not coming from PEP (i.e. main server) @param itemsEvent(pubsub.ItemsEvent): pubsub event - @param profile(unicode): %(doc_profile)s """ if itemsEvent.sender.user or itemsEvent.sender.resource: - log.debug("ignoring non PEP event from {} (profile={})".format(itemsEvent.sender.full(), profile)) + log.debug("ignoring non PEP event from {} (profile={})".format(itemsEvent.sender.full(), client.profile)) return - in_callback(itemsEvent, profile) + in_callback(itemsEvent, client.profile) self.host.plugins["XEP-0060"].addManagedNode(node, items_cb=filterPEPEvent)
--- a/src/plugins/plugin_xep_0277.py Wed Jul 05 15:02:52 2017 +0200 +++ b/src/plugins/plugin_xep_0277.py Wed Jul 05 15:04:43 2017 +0200 @@ -112,10 +112,10 @@ ## plugin management methods ## - def _itemsReceived(self, itemsEvent, profile): + def _itemsReceived(self, client, itemsEvent): """Callback which manage items notifications (publish + retract)""" def manageItem(data, event): - self.host.bridge.psEvent(C.PS_MICROBLOG, itemsEvent.sender.full(), itemsEvent.nodeIdentifier, event, data, profile) + self.host.bridge.psEvent(C.PS_MICROBLOG, itemsEvent.sender.full(), itemsEvent.nodeIdentifier, event, data, client.profile) for item in itemsEvent.items: if item.name == C.PS_ITEM: