plugin groupblog: fixed GROUP and JID publishers_type in getMassiveLastGroupBlogs and massiveSubscribeGroupBlogs
This commit is contained in:
parent
ef6dbda917
commit
faf878968b
1 changed files with 39 additions and 21 deletions
|
|
@ -70,6 +70,9 @@ class BadAccessTypeError(Exception):
|
|||
class BadAccessListError(Exception):
|
||||
pass
|
||||
|
||||
class UnknownType(Exception):
|
||||
pass
|
||||
|
||||
class GroupBlog():
|
||||
"""This class use a SàT PubSub Service to manage access on microblog"""
|
||||
|
||||
|
|
@ -271,17 +274,26 @@ class GroupBlog():
|
|||
if publishers_type == "ALL":
|
||||
contacts = client.roster.getItems()
|
||||
jids = [contact.jid.userhost() for contact in contacts]
|
||||
mblogs = []
|
||||
for _jid in jids:
|
||||
d = self.host.plugins["XEP-0060"].getItems(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)),
|
||||
max_items=max_items, profile_key=profile_key)
|
||||
d.addCallback(lambda items, source_jid: (source_jid, map(self.host.plugins["XEP-0277"].item2mbdata, items)), _jid)
|
||||
mblogs.append(d)
|
||||
dlist = defer.DeferredList(mblogs)
|
||||
dlist.addCallback(sendResult)
|
||||
return dlist
|
||||
|
||||
return defer.fail("Unknown type")
|
||||
elif publishers_type == "GROUP":
|
||||
jids = []
|
||||
for _group in publishers:
|
||||
jids.extend(client.roster.getJidsFromGroup(_group))
|
||||
elif publishers_type == 'JID':
|
||||
jids = publishers
|
||||
else:
|
||||
raise UnknownType
|
||||
|
||||
mblogs = []
|
||||
|
||||
for _jid in jids:
|
||||
d = self.host.plugins["XEP-0060"].getItems(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)),
|
||||
max_items=max_items, profile_key=profile_key)
|
||||
d.addCallback(lambda items, source_jid: (source_jid, map(self.host.plugins["XEP-0277"].item2mbdata, items)), _jid)
|
||||
mblogs.append(d)
|
||||
dlist = defer.DeferredList(mblogs)
|
||||
dlist.addCallback(sendResult)
|
||||
|
||||
return dlist
|
||||
|
||||
|
||||
#TODO: custom exception
|
||||
|
|
@ -315,15 +327,22 @@ class GroupBlog():
|
|||
if publishers_type == "ALL":
|
||||
contacts = client.roster.getItems()
|
||||
jids = [contact.jid.userhost() for contact in contacts]
|
||||
mblogs = []
|
||||
for _jid in jids:
|
||||
d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)),
|
||||
profile_key=profile_key)
|
||||
mblogs.append(d)
|
||||
dlist = defer.DeferredList(mblogs)
|
||||
return dlist
|
||||
elif publishers_type == "GROUP":
|
||||
jids = []
|
||||
for _group in publishers:
|
||||
jids.extend(client.roster.getJidsFromGroup(_group))
|
||||
elif publishers_type == 'JID':
|
||||
jids = publishers
|
||||
else:
|
||||
raise UnknownType
|
||||
|
||||
return defer.fail("Unknown type")
|
||||
mblogs = []
|
||||
for _jid in jids:
|
||||
d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)),
|
||||
profile_key=profile_key)
|
||||
mblogs.append(d)
|
||||
dlist = defer.DeferredList(mblogs)
|
||||
return dlist
|
||||
|
||||
|
||||
#TODO: custom exception
|
||||
|
|
|
|||
Loading…
Reference in a new issue