core: findByFeatures fixes
This commit is contained in:
parent
6fe84eb8bf
commit
8792a16337
1 changed files with 17 additions and 40 deletions
|
|
@ -811,41 +811,15 @@ class SAT(service.Service):
|
|||
def findFeaturesSet(self, *args, **kwargs):
|
||||
return self.memory.disco.findFeaturesSet(*args, **kwargs)
|
||||
|
||||
def _findByFeatures(
|
||||
self,
|
||||
namespaces,
|
||||
identities,
|
||||
bare_jids,
|
||||
service,
|
||||
roster,
|
||||
own_jid,
|
||||
local_device,
|
||||
profile_key,
|
||||
):
|
||||
def _findByFeatures(self, namespaces, identities, bare_jids, service, roster, own_jid,
|
||||
local_device, profile_key):
|
||||
client = self.getClient(profile_key)
|
||||
return self.findByFeatures(
|
||||
client,
|
||||
namespaces,
|
||||
identities,
|
||||
bare_jids,
|
||||
service,
|
||||
roster,
|
||||
own_jid,
|
||||
local_device,
|
||||
)
|
||||
return self.findByFeatures(client, namespaces, identities, bare_jids, service,
|
||||
roster, own_jid, local_device,)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def findByFeatures(
|
||||
self,
|
||||
client,
|
||||
namespaces,
|
||||
identities=None,
|
||||
bare_jids=False,
|
||||
service=True,
|
||||
roster=True,
|
||||
own_jid=True,
|
||||
local_device=False,
|
||||
):
|
||||
def findByFeatures(self, client, namespaces, identities=None, bare_jids=False,
|
||||
service=True, roster=True, own_jid=True, local_device=False):
|
||||
"""retrieve all services or contacts managing a set a features
|
||||
|
||||
@param namespaces(list[unicode]): features which must be handled
|
||||
|
|
@ -865,6 +839,7 @@ class SAT(service.Service):
|
|||
- own entities
|
||||
- roster entities
|
||||
"""
|
||||
assert isinstance(namespaces, list)
|
||||
if not identities:
|
||||
identities = None
|
||||
if not namespaces and not identities:
|
||||
|
|
@ -888,16 +863,13 @@ class SAT(service.Service):
|
|||
]
|
||||
found_service[service_jid.full()] = found_identities
|
||||
|
||||
jids = []
|
||||
if roster:
|
||||
jids.extend(client.roster.getJids())
|
||||
to_find = []
|
||||
if own_jid:
|
||||
jids.append(client.jid.userhostJID())
|
||||
to_find.append((found_own, [client.jid.userhostJID()]))
|
||||
if roster:
|
||||
to_find.append((found_roster, client.roster.getJids()))
|
||||
|
||||
for found, jids in (
|
||||
(found_own, [client.jid.userhostJID()]),
|
||||
(found_roster, client.roster.getJids()),
|
||||
):
|
||||
for found, jids in to_find:
|
||||
for jid_ in jids:
|
||||
if jid_.resource:
|
||||
if bare_jids:
|
||||
|
|
@ -911,6 +883,11 @@ class SAT(service.Service):
|
|||
resources = self.memory.getAvailableResources(client, jid_)
|
||||
except exceptions.UnknownEntityError:
|
||||
continue
|
||||
if not resources and jid_ == client.jid.userhostJID() and own_jid:
|
||||
# small hack to avoid missing our own resource when this
|
||||
# method is called at the very beginning of the session
|
||||
# and our presence has not been received yet
|
||||
resources = [client.jid.resource]
|
||||
for resource in resources:
|
||||
full_jid = jid.JID(tuple=(jid_.user, jid_.host, resource))
|
||||
if full_jid == client.jid and not local_device:
|
||||
|
|
|
|||
Loading…
Reference in a new issue