Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
311:0aa6ca6cdbdd | 312:f56108eb2880 |
---|---|
65 def __init__(self, host): | 65 def __init__(self, host): |
66 info(_("Group blog plugin initialization")) | 66 info(_("Group blog plugin initialization")) |
67 self.host = host | 67 self.host = host |
68 self._blog_nodes={} | 68 self._blog_nodes={} |
69 for i in range(1,21): | 69 for i in range(1,21): |
70 self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.host.plugins["XEP-0277"].microblogCB, None) | 70 self.host.plugins["XEP-0163"].addPEPEvent("MICROBLOG_%02d" % i, NS_MICROBLOG % i, self.groupblogCB, None) |
71 | 71 |
72 host.bridge.addMethod("cleanBlogCollection", ".communication", in_sign='s', out_sign='', | 72 host.bridge.addMethod("cleanBlogCollection", ".communication", in_sign='s', out_sign='', |
73 method=self.cleanBlogCollection, | 73 method=self.cleanBlogCollection, |
74 doc = { | 74 doc = { |
75 }) | 75 }) |
94 method=self.subscribeGroupBlog, | 94 method=self.subscribeGroupBlog, |
95 doc = { 'summary':"Subscribe to the group blog of somebody", | 95 doc = { 'summary':"Subscribe to the group blog of somebody", |
96 'param_0':'jid of the group node published', | 96 'param_0':'jid of the group node published', |
97 'param_1':'%(doc_profile)s' | 97 'param_1':'%(doc_profile)s' |
98 }) | 98 }) |
99 | |
100 def groupblogCB(self, itemsEvent, profile): | |
101 for item in itemsEvent.items: | |
102 microblog_data = self.host.plugins["XEP-0277"]._item2mbdata(item) | |
103 microblog_data["node"] = itemsEvent.nodeIdentifier | |
104 microblog_data["groups"] = "\n".join(self._blog_nodes[profile].get(itemsEvent.nodeIdentifier, [])) | |
105 self.host.bridge.personalEvent(itemsEvent.sender.full(), "MICROBLOG", microblog_data, profile) | |
99 | 106 |
100 def _getRootNode(self, entity): | 107 def _getRootNode(self, entity): |
101 return "%(entity)s_%(root_suff)s" % {'entity':entity.userhost(), 'root_suff':MBLOG_COLLECTION} | 108 return "%(entity)s_%(root_suff)s" % {'entity':entity.userhost(), 'root_suff':MBLOG_COLLECTION} |
102 | 109 |
103 def _getNodeName(self, number): | 110 def _getNodeName(self, number): |