plugin XEP-0277, group blogs: proper asynchronous methods for sending blogs.
This commit is contained in:
parent
86e9bf62c7
commit
e23ff9f8d1
1 changed files with 19 additions and 19 deletions
|
|
@ -85,7 +85,8 @@ class GroupBlog(object):
|
|||
self.host = host
|
||||
|
||||
host.bridge.addMethod("sendGroupBlog", ".plugin", in_sign='sassa{ss}s', out_sign='',
|
||||
method=self.sendGroupBlog)
|
||||
method=self.sendGroupBlog,
|
||||
async=True)
|
||||
|
||||
host.bridge.addMethod("sendGroupBlogComment", ".plugin", in_sign='sss', out_sign='',
|
||||
method=self.sendGroupBlogComment,
|
||||
|
|
@ -296,6 +297,7 @@ class GroupBlog(object):
|
|||
|
||||
defer_blog = self.host.plugins["XEP-0060"].publish(service, node_name, items=[mblog_item], profile_key=client.profile)
|
||||
defer_blog.addErrback(self._mblogPublicationFailed)
|
||||
return defer_blog
|
||||
|
||||
def _mblogPublicationFailed(self, failure):
|
||||
#TODO
|
||||
|
|
@ -317,19 +319,19 @@ class GroupBlog(object):
|
|||
if access_type == "PUBLIC":
|
||||
if access_list:
|
||||
raise Exception("Publishers list must be empty when getting microblogs for all contacts")
|
||||
self._publishMblog(client.item_access_pubsub, client, "PUBLIC", [], message, extra)
|
||||
return self._publishMblog(client.item_access_pubsub, client, "PUBLIC", [], message, extra)
|
||||
elif access_type == "GROUP":
|
||||
_groups = set(access_list).intersection(client.roster.getGroups()) # We only keep group which actually exist
|
||||
if not _groups:
|
||||
raise BadAccessListError("No valid group")
|
||||
self._publishMblog(client.item_access_pubsub, client, "GROUP", _groups, message, extra)
|
||||
return self._publishMblog(client.item_access_pubsub, client, "GROUP", _groups, message, extra)
|
||||
elif access_type == "JID":
|
||||
raise NotImplementedError
|
||||
else:
|
||||
error(_("Unknown access type"))
|
||||
raise BadAccessTypeError
|
||||
|
||||
self.initialise(profile_key).addCallback(initialised)
|
||||
return self.initialise(profile_key).addCallback(initialised)
|
||||
|
||||
def sendGroupBlogComment(self, node_url, message, profile_key='@NONE@'):
|
||||
"""Publish a comment in the given node
|
||||
|
|
|
|||
Loading…
Reference in a new issue