Allow disco info/items handlers to return full Iq stanzas.

Only allowing handlers to return a DiscoInfo/DiscoItem stanza works
for the majority of cases, but does not allow for the addition of
an RSM stanza, or other extensions.

An Iq stanza returned by a handler must already be configured as
a reply.
This commit is contained in:
Lance Stout 2011-12-12 19:38:32 -08:00
parent 85e9042db6
commit fc8a13df5a

View file

@ -551,11 +551,14 @@ class xep_0030(base_plugin):
jid, jid,
iq['disco_info']['node'], iq['disco_info']['node'],
iq) iq)
iq.reply() if isinstance(info, Iq):
if info: info.send()
info = self._fix_default_info(info) else:
iq.set_payload(info.xml) iq.reply()
iq.send() if info:
info = self._fix_default_info(info)
iq.set_payload(info.xml)
iq.send()
elif iq['type'] == 'result': elif iq['type'] == 'result':
log.debug("Received disco info result from" + \ log.debug("Received disco info result from" + \
"%s to %s.", iq['from'], iq['to']) "%s to %s.", iq['from'], iq['to'])
@ -581,10 +584,13 @@ class xep_0030(base_plugin):
jid, jid,
iq['disco_items']['node'], iq['disco_items']['node'],
iq) iq)
iq.reply() if isinstance(items, Iq):
if items: items.send()
iq.set_payload(items.xml) else:
iq.send() iq.reply()
if items:
iq.set_payload(items.xml)
iq.send()
elif iq['type'] == 'result': elif iq['type'] == 'result':
log.debug("Received disco items result from" + \ log.debug("Received disco items result from" + \
"%s to %s.", iq['from'], iq['to']) "%s to %s.", iq['from'], iq['to'])