changeset 3454:c424bfb927b1

mod_cache_c2s_caps: Switch to the new module:send_iq() API.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 22 Jan 2019 15:38:09 +0100
parents 41e1cacf3c4e
children 1ef702d30b6b
files mod_cache_c2s_caps/mod_cache_c2s_caps.lua
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mod_cache_c2s_caps/mod_cache_c2s_caps.lua	Mon Jan 21 19:52:04 2019 +0100
+++ b/mod_cache_c2s_caps/mod_cache_c2s_caps.lua	Tue Jan 22 15:38:09 2019 +0100
@@ -26,7 +26,6 @@
 		query.attr.node = node_query;
 	end
 	iq_node_map[from..id] = nil;
-	in_flight_iqs[from..node_string] = nil;
 
 	if node_string ~= node_query then
 		origin.log("debug", "Wrong node for our disco#info query, expected %s, received %s", node_string, node_query);
@@ -88,11 +87,10 @@
 	iq_node_map[from..id] = node_query
 	local iq = st_iq({ type = "get", from = module.host, to = from, id = id })
 		:tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node_query });
-	module:hook("iq-result/host/"..id, iq_result_handler);
-	module:hook("iq-error/host/"..id, iq_error_handler);
-	module:send(iq);
-
 	in_flight_iqs[from..node_query] = true;
+	module:send_iq(iq, origin)
+		:next(iq_result_handler, iq_error_handler)
+		:finally(function () in_flight_iqs[from..node_query] = nil; end)
 end
 
 -- Handle only non-directed presences for now.