comparison src/plugins/plugin_misc_groupblog.py @ 1419:be2df1ddea8e

plugins (groupblog, xep-0277) + tmp(rsm): improved style: - removed external parenthesis in assertions - added blank line after first line of docstrings - replaced "__" prefixes by "_" - renamed variabled named after the reserverd word "max" to "max_"
author Goffi <goffi@goffi.org>
date Wed, 22 Apr 2015 18:30:28 +0200
parents 3265a2639182
children 7c0acb966fd6
comparison
equal deleted inserted replaced
1418:6adf1b0be609 1419:be2df1ddea8e
212 return False 212 return False
213 return True 213 return True
214 214
215 def _handleCommentsItems(self, items, service, node_identifier): 215 def _handleCommentsItems(self, items, service, node_identifier):
216 """ Convert comments items to groupblog data, and send them as signals 216 """ Convert comments items to groupblog data, and send them as signals
217
217 @param items: comments items 218 @param items: comments items
218 @param service: jid of the PubSub service used 219 @param service: jid of the PubSub service used
219 @param node_identifier: comments node 220 @param node_identifier: comments node
220 @return: deferred list of group blog data 221 @return: deferred list of group blog data
221 """ 222 """
259 self._parseAccessData(microblog_data, item) 260 self._parseAccessData(microblog_data, item)
260 defer.returnValue(microblog_data) 261 defer.returnValue(microblog_data)
261 262
262 def getNodeName(self, publisher): 263 def getNodeName(self, publisher):
263 """Retrieve the name of publisher's node 264 """Retrieve the name of publisher's node
265
264 @param publisher: publisher's jid 266 @param publisher: publisher's jid
265 @return: node's name (string)""" 267 @return: node's name (string)
268 """
266 return NS_NODE_PREFIX + publisher.userhost() 269 return NS_NODE_PREFIX + publisher.userhost()
267 270
268 def _publishMblog(self, service, client, access_type, access_list, message, extra): 271 def _publishMblog(self, service, client, access_type, access_list, message, extra):
269 """Actually publish the message on the group blog 272 """Actually publish the message on the group blog
273
270 @param service: jid of the item-access pubsub service 274 @param service: jid of the item-access pubsub service
271 @param client: SatXMPPClient of the publisher 275 @param client: SatXMPPClient of the publisher
272 @param access_type: one of "PUBLIC", "GROUP", "JID" 276 @param access_type: one of "PUBLIC", "GROUP", "JID"
273 @param access_list: set of entities (empty list for all, groups or jids) allowed to see the item 277 @param access_list: set of entities (empty list for all, groups or jids) allowed to see the item
274 @param message: message to publish 278 @param message: message to publish
743 #TODO: we need to use the server corresponding the the host of the jid 747 #TODO: we need to use the server corresponding the the host of the jid
744 748
745 jids = self._getPublishersJIDs(publishers_type, publishers, client) 749 jids = self._getPublishersJIDs(publishers_type, publishers, client)
746 node_ids = [self.getNodeName(publisher) for publisher in jids] 750 node_ids = [self.getNodeName(publisher) for publisher in jids]
747 d_list = yield self.host.plugins["XEP-0060"].subscribeToMany(client.item_access_pubsub, node_ids, profile_key=profile_key) 751 d_list = yield self.host.plugins["XEP-0060"].subscribeToMany(client.item_access_pubsub, node_ids, profile_key=profile_key)
748 result = yield defer.DeferredList(d_list, consumeErrors=False) 752 yield defer.DeferredList(d_list, consumeErrors=False)
749 defer.returnValue(None) 753 defer.returnValue(None)
750 754
751 def deleteAllGroupBlogsAndComments(self, profile_key=C.PROF_KEY_NONE): 755 def deleteAllGroupBlogsAndComments(self, profile_key=C.PROF_KEY_NONE):
752 """Delete absolutely all the microblog data that the user has posted""" 756 """Delete absolutely all the microblog data that the user has posted"""
753 calls = [self.deleteAllGroupBlogs(profile_key), self.deleteAllGroupBlogsComments(profile_key)] 757 calls = [self.deleteAllGroupBlogs(profile_key), self.deleteAllGroupBlogsComments(profile_key)]