mod_poke_strangers: Create only one hook, re-use the UUIDs.
--- 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