Mercurial > prosody-modules
changeset 3317:36a9170352b5
mod_delegation: Update to generate own iq ids
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 13 Sep 2018 16:28:10 +0100 |
parents | 9d8098f4b652 |
children | 1856c3aae92d |
files | mod_delegation/mod_delegation.lua |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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)