plugins xep-0277, groupblog: added subscriteToMany to replace massiveSubscribeGroupBlogs + added SatRosterProtocol.getJidsSet
This commit is contained in:
parent
d4008f22ec
commit
2b20bff614
2 changed files with 115 additions and 46 deletions
|
|
@ -81,6 +81,11 @@ class Const(object):
|
|||
ENTITY_MAIN_RESOURCE = '@MAIN_RESOURCE@'
|
||||
ENTITY_CAP_HASH = 'CAP_HASH'
|
||||
|
||||
## Roster jids selection ##
|
||||
ALL = 'ALL'
|
||||
GROUP = 'GROUP'
|
||||
JID = 'JID'
|
||||
|
||||
|
||||
## Messages ##
|
||||
MESS_TYPE_INFO = 'info'
|
||||
|
|
|
|||
|
|
@ -307,6 +307,28 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
|
|||
except KeyError:
|
||||
raise exceptions.UnknownGroupError(group)
|
||||
|
||||
def getJidsSet(self, type_, groups=None):
|
||||
"""Helper method to get a set of jids
|
||||
|
||||
@param type_(unicode): one of:
|
||||
C.ALL: get all jids from roster
|
||||
C.GROUP: get jids from groups (listed in "groups")
|
||||
@groups(list[unicode]): list of groups used if type_==C.GROUP
|
||||
@return (set(jid.JID)): set of selected jids
|
||||
"""
|
||||
if type_ == C.ALL and groups is not None:
|
||||
raise ValueError('groups must not be set for {} type'.format(C.ALL))
|
||||
|
||||
if type_ == C.ALL:
|
||||
return set(self.getJids())
|
||||
elif type_ == C.GROUP:
|
||||
jids = set()
|
||||
for group in groups:
|
||||
jids.update(self.getJidsFromGroup(group))
|
||||
return jids
|
||||
else:
|
||||
raise ValueError(u'Unexpected type_ {}'.format(type_))
|
||||
|
||||
|
||||
class SatPresenceProtocol(xmppim.PresenceClientProtocol):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue