Software /
code /
prosody-modules
Diff
mod_poke_strangers/mod_poke_strangers.lua @ 2045:0aa8aa6cdb1b
mod_poke_strangers: Create only one hook, re-use the UUIDs.
author | Thijs Alkemade <me@thijsalkema.de> |
---|---|
date | Fri, 05 Feb 2016 11:37:47 +0100 |
parent | 2044:06faf7a149e3 |
child | 5852:1e28f32257d6 |
line wrap: on
line diff
--- a/mod_poke_strangers/mod_poke_strangers.lua Fri Feb 05 11:23:13 2016 +0100 +++ b/mod_poke_strangers/mod_poke_strangers.lua Fri Feb 05 11:37:47 2016 +0100 @@ -7,6 +7,19 @@ local recently_queried = set.new(); +local version_id = uuid_generate(); +local disco_id = uuid_generate(); + +module:hook("iq-result/host/" .. version_id, function (event) + module:log("info", "Stranger " .. event.stanza.attr.from .. " version: " .. tostring(event.stanza)); + return true; +end); + +module:hook("iq-result/host/" .. disco_id, function (event) + module:log("info", "Stranger " .. event.stanza.attr.from .. " disco: " .. tostring(event.stanza)); + return true; +end); + function check_subscribed(event) local stanza = event.stanza; local local_user_jid = stanza.attr.to; @@ -27,23 +40,8 @@ recently_queried:add(stranger_jid); - local version_id = uuid_generate(); - - module:hook("iq-result/host/" .. version_id, function (event) - module:log("info", "Stranger " .. stranger_jid .. " version: " .. tostring(event.stanza)); - return true; - end); - module:send(st.iq({ type = "get", to = stranger_jid, from = to_host, id = version_id }):query("jabber:iq:version")); - - local disco_id = uuid_generate(); - - module:hook("iq-result/host/" .. disco_id, function (event) - module:log("info", "Stranger " .. stranger_jid .. " disco: " .. tostring(event.stanza)); - return true; - end); - module:send(st.iq({ type = "get", to = stranger_jid, from = to_host, id = disco_id }):query("http://jabber.org/protocol/disco#info")); end