Fix issues of disco info leaking between entities with the same bare JIDs.
To ensure that disco info, or any settings which depend on the bound JID, are correct, only set such information on or after the session_bound event has fired.
This commit is contained in:
parent
7d20f0e9a6
commit
1baae1b81e
4 changed files with 10 additions and 20 deletions
|
@ -99,7 +99,7 @@ class APIRegistry(object):
|
||||||
"""
|
"""
|
||||||
self._setup(ctype, op)
|
self._setup(ctype, op)
|
||||||
|
|
||||||
if jid in (None, ''):
|
if not jid:
|
||||||
jid = self.xmpp.boundjid
|
jid = self.xmpp.boundjid
|
||||||
if jid and not isinstance(jid, JID):
|
if jid and not isinstance(jid, JID):
|
||||||
jid = JID(jid)
|
jid = JID(jid)
|
||||||
|
@ -113,7 +113,7 @@ class APIRegistry(object):
|
||||||
else:
|
else:
|
||||||
jid = jid.full
|
jid = jid.full
|
||||||
else:
|
else:
|
||||||
if self.settings[ctype].get('client_bare', True):
|
if self.settings[ctype].get('client_bare', False):
|
||||||
jid = jid.bare
|
jid = jid.bare
|
||||||
else:
|
else:
|
||||||
jid = jid.full
|
jid = jid.full
|
||||||
|
|
|
@ -622,11 +622,7 @@ class XEP_0030(BasePlugin):
|
||||||
if iq['type'] == 'get':
|
if iq['type'] == 'get':
|
||||||
log.debug("Received disco info query from " + \
|
log.debug("Received disco info query from " + \
|
||||||
"<%s> to <%s>.", iq['from'], iq['to'])
|
"<%s> to <%s>.", iq['from'], iq['to'])
|
||||||
if self.xmpp.is_component:
|
info = self.api['get_info'](iq['to'],
|
||||||
jid = iq['to'].full
|
|
||||||
else:
|
|
||||||
jid = iq['to'].bare
|
|
||||||
info = self.api['get_info'](jid,
|
|
||||||
iq['disco_info']['node'],
|
iq['disco_info']['node'],
|
||||||
iq['from'],
|
iq['from'],
|
||||||
iq)
|
iq)
|
||||||
|
@ -649,7 +645,7 @@ class XEP_0030(BasePlugin):
|
||||||
ito = iq['to'].full
|
ito = iq['to'].full
|
||||||
else:
|
else:
|
||||||
ito = None
|
ito = None
|
||||||
self.api['cache_info'](iq['from'].full,
|
self.api['cache_info'](iq['from'],
|
||||||
iq['disco_info']['node'],
|
iq['disco_info']['node'],
|
||||||
ito,
|
ito,
|
||||||
iq)
|
iq)
|
||||||
|
@ -667,13 +663,9 @@ class XEP_0030(BasePlugin):
|
||||||
if iq['type'] == 'get':
|
if iq['type'] == 'get':
|
||||||
log.debug("Received disco items query from " + \
|
log.debug("Received disco items query from " + \
|
||||||
"<%s> to <%s>.", iq['from'], iq['to'])
|
"<%s> to <%s>.", iq['from'], iq['to'])
|
||||||
if self.xmpp.is_component:
|
items = self.api['get_items'](iq['to'],
|
||||||
jid = iq['to'].full
|
|
||||||
else:
|
|
||||||
jid = iq['to'].bare
|
|
||||||
items = self.api['get_items'](jid,
|
|
||||||
iq['disco_items']['node'],
|
iq['disco_items']['node'],
|
||||||
iq['from'].full,
|
iq['from'],
|
||||||
iq)
|
iq)
|
||||||
if isinstance(items, Iq):
|
if isinstance(items, Iq):
|
||||||
items.send()
|
items.send()
|
||||||
|
|
|
@ -237,7 +237,7 @@ class StaticDisco(object):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if not self.node_exists(jid, node):
|
if not self.node_exists(jid, node):
|
||||||
if not node:
|
if not node:
|
||||||
return DiscoInfo()
|
return DiscoItems()
|
||||||
else:
|
else:
|
||||||
raise XMPPError(condition='item-not-found')
|
raise XMPPError(condition='item-not-found')
|
||||||
else:
|
else:
|
||||||
|
@ -424,9 +424,6 @@ class StaticDisco(object):
|
||||||
The data parameter is not used.
|
The data parameter is not used.
|
||||||
"""
|
"""
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if isinstance(jid, JID):
|
|
||||||
jid = jid.full
|
|
||||||
|
|
||||||
if not self.node_exists(jid, node, ifrom):
|
if not self.node_exists(jid, node, ifrom):
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -78,11 +78,12 @@ class XEP_0115(BasePlugin):
|
||||||
disco = self.xmpp['xep_0030']
|
disco = self.xmpp['xep_0030']
|
||||||
self.static = StaticCaps(self.xmpp, disco.static)
|
self.static = StaticCaps(self.xmpp, disco.static)
|
||||||
|
|
||||||
self.api.settings['client_bare'] = False
|
|
||||||
self.api.settings['component_bare'] = False
|
|
||||||
for op in self._disco_ops:
|
for op in self._disco_ops:
|
||||||
self.api.register(getattr(self.static, op), op, default=True)
|
self.api.register(getattr(self.static, op), op, default=True)
|
||||||
|
|
||||||
|
for op in ('supports', 'has_identity'):
|
||||||
|
self.xmpp['xep_0030'].api.register(getattr(self.static, op), op)
|
||||||
|
|
||||||
self._run_node_handler = disco._run_node_handler
|
self._run_node_handler = disco._run_node_handler
|
||||||
|
|
||||||
disco.cache_caps = self.cache_caps
|
disco.cache_caps = self.cache_caps
|
||||||
|
|
Loading…
Reference in a new issue