diff src/plugins/plugin_misc_groupblog.py @ 704:3c304929af74

plugin XEP-0277, group blogs: proper asynchronous methods for sending blogs.
author Goffi <goffi@goffi.org>
date Thu, 14 Nov 2013 17:51:35 +0100
parents 0c2c1dfb79e4
children 80e9d3ecb272
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Thu Nov 14 16:49:57 2013 +0100
+++ b/src/plugins/plugin_misc_groupblog.py	Thu Nov 14 17:51:35 2013 +0100
@@ -85,7 +85,8 @@
         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 @@
 
         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 @@
             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