comparison mod_cache_c2s_caps/mod_cache_c2s_caps.lua @ 3456:b85622b577ad

mod_cache_c2s_caps: Unset the caps_cache also on errors due to the result validation.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 22 Jan 2019 15:39:35 +0100
parents 1ef702d30b6b
children 13b394b0db82
comparison
equal deleted inserted replaced
3455:1ef702d30b6b 3456:b85622b577ad
12 local origin, stanza = event.origin, event.stanza; 12 local origin, stanza = event.origin, event.stanza;
13 13
14 local query = stanza:get_child("query", "http://jabber.org/protocol/disco#info"); 14 local query = stanza:get_child("query", "http://jabber.org/protocol/disco#info");
15 if not query then 15 if not query then
16 origin.log("debug", "Wrong iq payload in disco#info result: %s", stanza); 16 origin.log("debug", "Wrong iq payload in disco#info result: %s", stanza);
17 origin.caps_cache = nil;
17 return; 18 return;
18 end 19 end
19 20
20 local from = stanza.attr.from; 21 local from = stanza.attr.from;
21 local id = stanza.attr.id; 22 local id = stanza.attr.id;
27 end 28 end
28 iq_node_map[from..id] = nil; 29 iq_node_map[from..id] = nil;
29 30
30 if node_string ~= node_query then 31 if node_string ~= node_query then
31 origin.log("debug", "Wrong node for our disco#info query, expected %s, received %s", node_string, node_query); 32 origin.log("debug", "Wrong node for our disco#info query, expected %s, received %s", node_string, node_query);
33 origin.caps_cache = nil;
32 return; 34 return;
33 end 35 end
34 36
35 local node, ver = node_query:match("([^#]+)#([^#]+)"); 37 local node, ver = node_query:match("([^#]+)#([^#]+)");
36 local hash = calculate_hash(query) 38 local hash = calculate_hash(query)
37 if ver ~= hash then 39 if ver ~= hash then
38 origin.log("debug", "Wrong hash for disco#info: %s ~= %s", ver, hash); 40 origin.log("debug", "Wrong hash for disco#info: %s ~= %s", ver, hash);
41 origin.caps_cache = nil;
39 return; 42 return;
40 end 43 end
41 44
42 origin.caps_cache = query; 45 origin.caps_cache = query;
43 origin.log("info", "Stored caps %s", ver); 46 origin.log("info", "Stored caps %s", ver);