# HG changeset patch # User Matthew Wild # Date 1536852490 -3600 # Node ID 36a9170352b5e3f9928e68bd1b9f368bca2fe08b # Parent 9d8098f4b6525fc3df06a2a98976a0babffa2260 mod_delegation: Update to generate own iq ids diff -r 9d8098f4b652 -r 36a9170352b5 mod_delegation/mod_delegation.lua --- a/mod_delegation/mod_delegation.lua Thu Sep 13 16:14:41 2018 +0100 +++ b/mod_delegation/mod_delegation.lua Thu Sep 13 16:28:10 2018 +0100 @@ -13,6 +13,8 @@ local st = require("util.stanza") local set = require("util.set") +local new_id = require("util.id").short; + local delegation_session = module:shared("/*/delegation/session") -- FIXME: temporarily needed for disco_items_hook, to be removed when clean implementation is done @@ -252,11 +254,11 @@ local function forward_iq(stanza, ns_data) local to_jid = ns_data.connected stanza.attr.xmlns = 'jabber:client' - local iq_stanza = st.iq({ from=module.host, to=to_jid, type="set" }) + local iq_id = new_id(); + local iq_stanza = st.iq({ from=module.host, to=to_jid, type="set", id = iq_id }) :tag("delegation", { xmlns=_DELEGATION_NS }) :tag("forwarded", { xmlns=_FORWARDED_NS }) :add_child(stanza) - local iq_id = iq_stanza.attr.id -- we save the original stanza to check the managing entity result if not stanza_cache[to_jid] then stanza_cache[to_jid] = {} end stanza_cache[to_jid][iq_id] = stanza @@ -475,11 +477,10 @@ for _, prefix in ipairs(_PREFIXES) do local node = prefix..namespace - local iq = st.iq({from=module.host, to=entity_jid, type='get'}) + local iq_id = new_id(); + local iq = st.iq({from=module.host, to=entity_jid, type='get', id = iq_id }) :tag('query', {xmlns=_DISCO_INFO_NS, node=node}) - local iq_id = iq.attr.id - module:hook("iq-result/host/"..iq_id, disco_result) module:hook("iq-error/host/"..iq_id, disco_error) module:send(iq)