Mercurial > libervia-backend
comparison src/plugins/plugin_misc_groupblog.py @ 616:8782f94e761e
plugin groupblog: comment item is specified through microblog data, there is no more a specific signal type
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 16 Jun 2013 18:49:02 +0200 |
parents | 6f4c31192c7c |
children | dafdbe28ca2f |
comparison
equal
deleted
inserted
replaced
615:6f4c31192c7c | 616:8782f94e761e |
---|---|
180 # Comment | 180 # Comment |
181 for item in event.items: | 181 for item in event.items: |
182 publisher = "" # FIXME: publisher attribute for item in SàT pubsub is not managed yet, so | 182 publisher = "" # FIXME: publisher attribute for item in SàT pubsub is not managed yet, so |
183 # publisher is not checked and can be easily spoofed. This need to be fixed | 183 # publisher is not checked and can be easily spoofed. This need to be fixed |
184 # quickly. | 184 # quickly. |
185 microblog_data = self.item2gbdata(item) | 185 microblog_data = self.item2gbdata(item, "comment") |
186 microblog_data["comments_service"] = event.sender.userhost() | 186 microblog_data["service"] = event.sender.userhost() |
187 microblog_data["comments_node"] = event.nodeIdentifier | 187 microblog_data["node"] = event.nodeIdentifier |
188 microblog_data["verified_publisher"] = "true" if publisher else "false" | 188 microblog_data["verified_publisher"] = "true" if publisher else "false" |
189 | 189 |
190 self.host.bridge.personalEvent(publisher.full() if publisher else microblog_data["author"], "MICROBLOG_COMMENT", microblog_data, profile) | 190 self.host.bridge.personalEvent(publisher.full() if publisher else microblog_data["author"], "MICROBLOG", microblog_data, profile) |
191 return False | 191 return False |
192 return True | 192 return True |
193 | 193 |
194 def _parseAccessData(self, microblog_data, item): | 194 def _parseAccessData(self, microblog_data, item): |
195 P = self.host.plugins["XEP-0060"] | 195 P = self.host.plugins["XEP-0060"] |
206 warning("No group found for roster access-model") | 206 warning("No group found for roster access-model") |
207 microblog_data["groups"] = '' | 207 microblog_data["groups"] = '' |
208 | 208 |
209 break | 209 break |
210 | 210 |
211 def item2gbdata(self, item): | 211 def item2gbdata(self, item, _type="main_item"): |
212 """ Convert item to microblog data dictionary + add access data """ | 212 """ Convert item to microblog data dictionary + add access data """ |
213 microblog_data = self.host.plugins["XEP-0277"].item2mbdata(item) | 213 microblog_data = self.host.plugins["XEP-0277"].item2mbdata(item) |
214 microblog_data["type"] = _type | |
214 self._parseAccessData(microblog_data, item) | 215 self._parseAccessData(microblog_data, item) |
215 return microblog_data | 216 return microblog_data |
216 | 217 |
217 def getNodeName(self, publisher): | 218 def getNodeName(self, publisher): |
218 """Retrieve the name of publisher's node | 219 """Retrieve the name of publisher's node |
338 gbdata = self.item2gbdata(item) | 339 gbdata = self.item2gbdata(item) |
339 ret.append(gbdata) | 340 ret.append(gbdata) |
340 # if there is a comments node, we subscribe to it | 341 # if there is a comments node, we subscribe to it |
341 if "comments_node" in gbdata and pub_jid.userhostJID() != client.jid.userhostJID(): | 342 if "comments_node" in gbdata and pub_jid.userhostJID() != client.jid.userhostJID(): |
342 try: | 343 try: |
343 self.host.plugins["XEP-0060"].subscribe(gbdata["comments_service"], gbdata["comments_node"], | 344 self.host.plugins["XEP-0060"].subscribe(jid.JID(gbdata["comments_service"]), gbdata["comments_node"], |
344 profile_key=client.profile) | 345 profile_key=client.profile) |
345 self.host.plugins["XEP-0060"].getItems(gbdata["comments_service"], gbdata["comments_node"], profile_key=client.profile) | 346 self.host.plugins["XEP-0060"].getItems(jid.JID(gbdata["comments_service"]), gbdata["comments_node"], profile_key=client.profile) |
346 except KeyError: | 347 except KeyError: |
347 warning("Missing key for comments") | 348 warning("Missing key for comments") |
348 return ret | 349 return ret |
349 | 350 |
350 def getLastGroupBlogs(self, pub_jid_s, max_items=10, profile_key='@DEFAULT@'): | 351 def getLastGroupBlogs(self, pub_jid_s, max_items=10, profile_key='@DEFAULT@'): |