plugin group blog: renamed options parameter as extra for consistency with sendMessage

This commit is contained in:
Goffi 2013-11-14 16:49:57 +01:00
commit 86e9bf62c7

View file

@ -240,14 +240,14 @@ class GroupBlog(object):
@return: node's name (string)"""
return NS_NODE_PREFIX + publisher.userhost()
def _publishMblog(self, service, client, access_type, access_list, message, options):
def _publishMblog(self, service, client, access_type, access_list, message, extra):
"""Actually publish the message on the group blog
@param service: jid of the item-access pubsub service
@param client: SatXMPPClient of the published
@param access_type: one of "PUBLIC", "GROUP", "JID"
@param access_list: set of entities (empty list for all, groups or jids) allowed to see the item
@param message: message to publish
@param options: dict which option name as key, which can be:
@param extra: dict which option name as key, which can be:
- allow_comments: True to accept comments, False else (default: False)
"""
node_name = self.getNodeName(client.jid)
@ -255,7 +255,7 @@ class GroupBlog(object):
P = self.host.plugins["XEP-0060"]
access_model_value = ACCESS_TYPE_MAP[access_type]
if options.get('allow_comments', 'False').lower() == 'true':
if extra.get('allow_comments', 'False').lower() == 'true':
comments_node = "%s_%s__%s" % (NS_COMMENT_PREFIX, str(uuid.uuid4()), node_name)
mblog_data['comments'] = "xmpp:%(service)s?%(query)s" % {'service': service.userhost(),
'query': urllib.urlencode([('node',comments_node.encode('utf-8'))])}
@ -301,13 +301,13 @@ class GroupBlog(object):
#TODO
return failure
def sendGroupBlog(self, access_type, access_list, message, options, profile_key='@NONE@'):
def sendGroupBlog(self, access_type, access_list, message, extra, profile_key='@NONE@'):
"""Publish a microblog with given item access
@param access_type: one of "PUBLIC", "GROUP", "JID"
@param access_list: list of authorized entity (empty list for PUBLIC ACCESS,
list of groups or list of jids) for this item
@param message: microblog
@param options: dict which option name as key, which can be:
@param extra: dict which option name as key, which can be:
- allow_comments: True to accept comments, False else (default: False)
@profile_key: %(doc_profile)s
"""
@ -317,12 +317,12 @@ class GroupBlog(object):
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, options)
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, options)
self._publishMblog(client.item_access_pubsub, client, "GROUP", _groups, message, extra)
elif access_type == "JID":
raise NotImplementedError
else: