diff src/plugins/plugin_misc_groupblog.py @ 312:f56108eb2880

plugin group blog: a custom cb is now used to specitfy node and groups targetted by the blog
author Goffi <goffi@goffi.org>
date Fri, 15 Apr 2011 02:03:10 +0200
parents 0aa6ca6cdbdd
children 0f9925193586
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Tue Apr 12 20:40:47 2011 +0200
+++ b/src/plugins/plugin_misc_groupblog.py	Fri Apr 15 02:03:10 2011 +0200
@@ -67,7 +67,7 @@
         self.host = host
         self._blog_nodes={}
         for i in range(1,21):
-            self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.host.plugins["XEP-0277"].microblogCB, None)
+            self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.groupblogCB, None)
 
         host.bridge.addMethod("cleanBlogCollection", ".communication", in_sign='s', out_sign='',
                                method=self.cleanBlogCollection,
@@ -96,6 +96,13 @@
                                        'param_0':'jid of the group node published',
                                        'param_1':'%(doc_profile)s'
                                      })
+    
+    def groupblogCB(self, itemsEvent, profile):
+        for item in itemsEvent.items:
+            microblog_data = self.host.plugins["XEP-0277"]._item2mbdata(item)
+            microblog_data["node"] = itemsEvent.nodeIdentifier
+            microblog_data["groups"] = "\n".join(self._blog_nodes[profile].get(itemsEvent.nodeIdentifier, []))
+            self.host.bridge.personalEvent(itemsEvent.sender.full(), "MICROBLOG", microblog_data, profile)
 
     def _getRootNode(self, entity):
         return "%(entity)s_%(root_suff)s" % {'entity':entity.userhost(), 'root_suff':MBLOG_COLLECTION}