# HG changeset patch # User Thijs Alkemade # Date 1454668667 -3600 # Node ID 0aa8aa6cdb1b06045dd5e40f38874af8306ed6d7 # Parent 06faf7a149e3727d96811467c296b281647e9fc4 mod_poke_strangers: Create only one hook, re-use the UUIDs. diff -r 06faf7a149e3 -r 0aa8aa6cdb1b mod_poke_strangers/mod_poke_strangers.lua --- 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