Comparison

plugins/mod_pep.lua @ 9540:8cdd7fec6aa7

mod_pep: Remove use of recipients table for signaling pending disco#items It stored the caps hash as a string in the recipients table while waiting for a disco#info response, then replaces it with the set of nodes that had +notify. This mixing of types is bad, so here it gets removed. This can be improved once an IQ tracking API (#714) is added.
author Kim Alvefur <zash@zash.se>
date Tue, 23 Oct 2018 22:54:15 +0200
parent 9538:07665733b332
child 9541:742977123168
comparison
equal deleted inserted replaced
9539:b30455212f89 9540:8cdd7fec6aa7
269 service_recipients = {}; 269 service_recipients = {};
270 recipients[service_name] = service_recipients; 270 recipients[service_name] = service_recipients;
271 end 271 end
272 272
273 local current = service_recipients[recipient]; 273 local current = service_recipients[recipient];
274 if not current or type(current) ~= "table" then 274 if not current then
275 current = empty_set; 275 current = empty_set;
276 end 276 end
277 277
278 if (current == empty_set or current:empty()) and (nodes == empty_set or nodes:empty()) then 278 if (current == empty_set or current:empty()) and (nodes == empty_set or nodes:empty()) then
279 return; 279 return;
320 else 320 else
321 recipients[username] = recipients[username] or {}; 321 recipients[username] = recipients[username] or {};
322 if hash_map[hash] then 322 if hash_map[hash] then
323 update_subscriptions(recipient, username, hash_map[hash]); 323 update_subscriptions(recipient, username, hash_map[hash]);
324 else 324 else
325 recipients[username][recipient] = hash; 325 -- COMPAT from ~= stanza.attr.to because OneTeam can't deal with missing from attribute
326 local from_bare = origin.type == "c2s" and origin.username.."@"..origin.host; 326 origin.send(
327 if is_self or origin.type ~= "c2s" or (recipients[from_bare] and recipients[from_bare][origin.full_jid]) ~= hash then 327 st.stanza("iq", {from=user_bare, to=stanza.attr.from, id="disco", type="get"})
328 -- COMPAT from ~= stanza.attr.to because OneTeam can't deal with missing from attribute 328 :tag("query", {xmlns = "http://jabber.org/protocol/disco#info", node = query_node})
329 origin.send( 329 );
330 st.stanza("iq", {from=user_bare, to=stanza.attr.from, id="disco", type="get"})
331 :tag("query", {xmlns = "http://jabber.org/protocol/disco#info", node = query_node})
332 );
333 end
334 end 330 end
335 end 331 end
336 end 332 end
337 elseif t == "unavailable" then 333 elseif t == "unavailable" then
338 update_subscriptions(stanza.attr.from, username); 334 update_subscriptions(stanza.attr.from, username);
363 if is_self then 359 if is_self then
364 username = origin.username; 360 username = origin.username;
365 user_bare = jid_join(username, host); 361 user_bare = jid_join(username, host);
366 end 362 end
367 local contact = stanza.attr.from; 363 local contact = stanza.attr.from;
368 local current = recipients[username] and recipients[username][contact]; 364 local ver = calculate_hash(disco.tags); -- calculate hash
369 if type(current) ~= "string" then return; end -- check if waiting for recipient's response
370 local ver = current;
371 if not string.find(current, "#") then
372 ver = calculate_hash(disco.tags); -- calculate hash
373 end
374 local notify = set_new(); 365 local notify = set_new();
375 for _, feature in pairs(disco.tags) do 366 for _, feature in pairs(disco.tags) do
376 if feature.name == "feature" and feature.attr.var then 367 if feature.name == "feature" and feature.attr.var then
377 local nfeature = feature.attr.var:match("^(.*)%+notify$"); 368 local nfeature = feature.attr.var:match("^(.*)%+notify$");
378 if nfeature then notify:add(nfeature); end 369 if nfeature then notify:add(nfeature); end