Fix how disco plugin looks up info and items for clients.

This commit is contained in:
Lance Stout 2011-01-15 10:08:35 -05:00
parent d7dea0c6cc
commit a2891d7608

View file

@ -177,7 +177,10 @@ class xep_0030(base_plugin):
elif node is None: elif node is None:
self._handlers[htype]['jid'][jid] = handler self._handlers[htype]['jid'][jid] = handler
elif jid is None: elif jid is None:
if self.xmpp.is_component:
jid = self.xmpp.boundjid.full jid = self.xmpp.boundjid.full
else:
jid = self.xmpp.boundjid.bare
self._handlers[htype]['node'][(jid, node)] = handler self._handlers[htype]['node'][(jid, node)] = handler
else: else:
self._handlers[htype]['node'][(jid, node)] = handler self._handlers[htype]['node'][(jid, node)] = handler
@ -500,7 +503,10 @@ class xep_0030(base_plugin):
data -- Optional, custom data to pass to the handler. data -- Optional, custom data to pass to the handler.
""" """
if jid is None: if jid is None:
if self.xmpp.is_component:
jid = self.xmpp.boundjid.full jid = self.xmpp.boundjid.full
else:
jid = self.xmpp.boundjid.bare
if node is None: if node is None:
node = '' node = ''
@ -526,8 +532,12 @@ class xep_0030(base_plugin):
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:
jid = iq['to'].full
else:
jid = iq['to'].bare
info = self._run_node_handler('get_info', info = self._run_node_handler('get_info',
iq['to'].full, jid,
iq['disco_info']['node'], iq['disco_info']['node'],
iq) iq)
iq.reply() iq.reply()
@ -552,8 +562,12 @@ class xep_0030(base_plugin):
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:
jid = iq['to'].full
else:
jid = iq['to'].bare
items = self._run_node_handler('get_items', items = self._run_node_handler('get_items',
iq['to'].full, jid,
iq['disco_items']['node']) iq['disco_items']['node'])
iq.reply() iq.reply()
if items: if items: