core: use of Twisted JID instead of string bare jid in roster SatRosterProtocol

This commit is contained in:
Goffi 2013-12-10 17:25:31 +01:00
commit 2ad1019de7

View file

@ -98,7 +98,7 @@ class GroupBlog(object):
host.bridge.addMethod("getMassiveLastGroupBlogs", ".plugin",
in_sign='sasis', out_sign='a{saa{ss}}',
method=self.getMassiveLastGroupBlogs,
method=self._getMassiveLastGroupBlogs,
async=True)
host.bridge.addMethod("getGroupBlogComments", ".plugin",
@ -111,7 +111,7 @@ class GroupBlog(object):
async=True)
host.bridge.addMethod("massiveSubscribeGroupBlogs", ".plugin", in_sign='sass', out_sign='',
method=self.massiveSubscribeGroupBlogs,
method=self._massiveSubscribeGroupBlogs,
async=True)
host.trigger.add("PubSubItemsReceived", self.pubSubItemsReceivedTrigger)
@ -435,6 +435,13 @@ class GroupBlog(object):
#TODO: we need to use the server corresponding the the host of the jid
return self._initialise(profile_key).addCallback(initialised)
def _getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key='@NONE@'):
if publishers_type == 'JID':
publishers_jids = [jid.JID(publisher) for publisher in publishers]
else:
publishers_jid = publishers
return getMassiveLastGroupBlogs(publishers_type, publishers_jid, max_items, profile_key)
def getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key='@NONE@'):
"""Get the last published microblogs for a list of groups or jids
@param publishers_type: type of the list of publishers (one of "GROUP" or "JID" or "ALL")
@ -460,7 +467,7 @@ class GroupBlog(object):
if publishers_type == "ALL":
contacts = client.roster.getItems()
jids = [contact.jid.userhost() for contact in contacts]
jids = [contact.jid.userhostJID() for contact in contacts]
elif publishers_type == "GROUP":
jids = []
for _group in publishers:
@ -473,12 +480,11 @@ class GroupBlog(object):
mblogs = []
for jid_s in jids:
_jid = jid.JID(jid_s)
d = self.host.plugins["XEP-0060"].getItems(client.item_access_pubsub, self.getNodeName(_jid),
for jid_ in jids:
d = self.host.plugins["XEP-0060"].getItems(client.item_access_pubsub, self.getNodeName(jid_),
max_items=max_items, profile_key=profile_key)
d.addCallback(self._itemsConstruction, _jid, client)
d.addCallback(lambda gbdata, source_jid: (source_jid, gbdata), jid_s)
d.addCallback(self._itemsConstruction, jid_, client)
d.addCallback(lambda gbdata, source_jid: (source_jid, gbdata), jid_.full())
mblogs.append(d)
dlist = defer.DeferredList(mblogs)
@ -504,6 +510,13 @@ class GroupBlog(object):
#TODO: we need to use the server corresponding the the host of the jid
return self._initialise(profile_key).addCallback(initialised)
def _massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key='@NONE@'):
if publishers_type == 'JID':
publishers_jids = [jid.JID(publisher) for publisher in publishers]
else:
publishers_jid = publishers
return massiveSubscribeGroupBlogs(publishers_type, publishers_jid, profile_key)
def massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key='@NONE@'):
"""Subscribe microblogs for a list of groups or jids
@param publishers_type: type of the list of publishers (one of "GROUP" or "JID" or "ALL")
@ -516,7 +529,7 @@ class GroupBlog(object):
if publishers_type == "ALL":
contacts = client.roster.getItems()
jids = [contact.jid.userhost() for contact in contacts]
jids = [contact.jid.userhostJID() for contact in contacts]
elif publishers_type == "GROUP":
jids = []
for _group in publishers:
@ -527,8 +540,8 @@ class GroupBlog(object):
raise UnknownType
mblogs = []
for _jid in jids:
d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)),
for jid_ in jids:
d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid_),
profile_key=profile_key)
mblogs.append(d)
dlist = defer.DeferredList(mblogs)