# HG changeset patch # User Goffi # Date 1510732639 -3600 # Node ID 014feb75092df1f8a2b465aea9df2fd8a88b6cfa # Parent c6d859df4b2747d04cf7599e7311d32e9f9540eb plugin XEP-0277: better getCommentsService: getCommentsService now checks if the parent service is on a third party server and if it's PEP, and return the service to use accordingly. diff -r c6d859df4b27 -r 014feb75092d src/plugins/plugin_xep_0277.py --- a/src/plugins/plugin_xep_0277.py Wed Nov 15 08:55:47 2017 +0100 +++ b/src/plugins/plugin_xep_0277.py Wed Nov 15 08:57:19 2017 +0100 @@ -474,9 +474,23 @@ """Get prefered PubSub service to create comment node @param pubsub_service(jid.JID, None): PubSub service of the parent item - @param return(jid.JID, None): PubSub service to use + @param return((D)jid.JID, None): PubSub service to use """ - return client.pubsub_service if client.pubsub_service is not None else parent_service + if parent_service is not None: + if parent_service.user: + # we are on a PEP + if parent_service.host == client.jid.host: + # it's our server, we use already found client.pubsub_service below + pass + else: + # other server, let's try to find a non PEP service there + d = self.host.findServiceEntity(client, "pubsub", "service", parent_service) + d.addCallback(lambda entity: entity or parent_service) + else: + # parent is already on a normal Pubsub service, we re-use it + return defer.succeed(parent_service) + + return defer.succeed(client.pubsub_service if client.pubsub_service is not None else parent_service) @defer.inlineCallbacks def _manageComments(self, client, mb_data, service, node, item_id, access=None):