comparison mod_cache_c2s_caps/mod_cache_c2s_caps.lua @ 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 7a3ac037e57f
children 1ef702d30b6b
comparison
equal deleted inserted replaced
3453:41e1cacf3c4e 3454:c424bfb927b1
24 if node_string == nil then 24 if node_string == nil then
25 node_string = node_query; 25 node_string = node_query;
26 query.attr.node = node_query; 26 query.attr.node = node_query;
27 end 27 end
28 iq_node_map[from..id] = nil; 28 iq_node_map[from..id] = nil;
29 in_flight_iqs[from..node_string] = nil;
30 29
31 if node_string ~= node_query then 30 if node_string ~= node_query then
32 origin.log("debug", "Wrong node for our disco#info query, expected %s, received %s", node_string, node_query); 31 origin.log("debug", "Wrong node for our disco#info query, expected %s, received %s", node_string, node_query);
33 return; 32 return;
34 end 33 end
86 85
87 local id = uuid_gen(); 86 local id = uuid_gen();
88 iq_node_map[from..id] = node_query 87 iq_node_map[from..id] = node_query
89 local iq = st_iq({ type = "get", from = module.host, to = from, id = id }) 88 local iq = st_iq({ type = "get", from = module.host, to = from, id = id })
90 :tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node_query }); 89 :tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node_query });
91 module:hook("iq-result/host/"..id, iq_result_handler);
92 module:hook("iq-error/host/"..id, iq_error_handler);
93 module:send(iq);
94
95 in_flight_iqs[from..node_query] = true; 90 in_flight_iqs[from..node_query] = true;
91 module:send_iq(iq, origin)
92 :next(iq_result_handler, iq_error_handler)
93 :finally(function () in_flight_iqs[from..node_query] = nil; end)
96 end 94 end
97 95
98 -- Handle only non-directed presences for now. 96 -- Handle only non-directed presences for now.
99 module:hook("pre-presence/bare", presence_stanza_handler); 97 module:hook("pre-presence/bare", presence_stanza_handler);