Mercurial > libervia-backend
diff src/plugins/plugin_misc_groupblog.py @ 1450:7797dda847ae
plugins xep-0277, groupblog: added subscriteToMany to replace massiveSubscribeGroupBlogs + added SatRosterProtocol.getJidsSet
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 15 Aug 2015 22:20:43 +0200 |
parents | 226bbe758b1a |
children | 5116d70ddd1c |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py Sat Aug 15 22:13:27 2015 +0200 +++ b/src/plugins/plugin_misc_groupblog.py Sat Aug 15 22:20:43 2015 +0200 @@ -137,9 +137,6 @@ method=self.subscribeGroupBlog, async=True) - host.bridge.addMethod("massiveSubscribeGroupBlogs", ".plugin", in_sign='sass', out_sign='', - method=self._massiveSubscribeGroupBlogs, - async=True) host.trigger.add("PubSubItemsReceived", self.pubSubItemsReceivedTrigger) @@ -658,25 +655,25 @@ publishers_jids = publishers return self.getMassiveGroupBlogs(publishers_type, publishers_jids, rsm_data, profile_key) - def _getPublishersJIDs(self, publishers_type, publishers, client): - #TODO: custom exception - if publishers_type not in ["GROUP", "JID", "ALL"]: - raise Exception("Bad call, unknown publishers_type") - if publishers_type == "ALL" and publishers: - raise Exception("Publishers list must be empty when getting microblogs for all contacts") + # def _getPublishersJIDs(self, publishers_type, publishers, client): + # #TODO: custom exception + # if publishers_type not in ["GROUP", "JID", "ALL"]: + # raise Exception("Bad call, unknown publishers_type") + # if publishers_type == "ALL" and publishers: + # raise Exception("Publishers list must be empty when getting microblogs for all contacts") - if publishers_type == "ALL": - contacts = client.roster.getItems() - jids = [contact.jid.userhostJID() for contact in contacts] - 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 jids + # if publishers_type == "ALL": + # contacts = client.roster.getItems() + # jids = [contact.jid.userhostJID() for contact in contacts] + # 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 jids def getMassiveGroupBlogs(self, publishers_type, publishers, rsm_data=None, profile_key=C.PROF_KEY_NONE): """Get the last published microblogs for a list of groups or jids @@ -709,28 +706,6 @@ #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=C.PROF_KEY_NONE): - if publishers_type == 'JID': - publishers_jids = [jid.JID(publisher) for publisher in publishers] - else: - publishers_jids = publishers - return self.massiveSubscribeGroupBlogs(publishers_type, publishers_jids, profile_key) - - @defer.inlineCallbacks - def massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key=C.PROF_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") - @param publishers: list of publishers, according to "publishers_type" (list of groups or list of jids) - @param profile_key: profile key - """ - profile, client = yield self._initialise(profile_key) - #TODO: we need to use the server corresponding the the host of the jid - - jids = self._getPublishersJIDs(publishers_type, publishers, client) - node_ids = [self.getNodeName(publisher) for publisher in jids] - d_list = yield self.host.plugins["XEP-0060"].subscribeToMany(client.item_access_pubsub, node_ids, profile_key=profile_key) - yield defer.DeferredList(d_list, consumeErrors=False) - defer.returnValue(None) ## delete ##