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.
This commit is contained in:
parent
7de0ba6c64
commit
bf91404351
1 changed files with 16 additions and 2 deletions
|
|
@ -474,9 +474,23 @@ class XEP_0277(object):
|
|||
"""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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue