Comparison

plugins/muc/muc.lib.lua @ 8912:43806beda970

MUC: Move extraction of <{muc}x> earlier, to be used later to differentiate between join and presence update
author Kim Alvefur <zash@zash.se>
date Fri, 09 Mar 2018 18:23:03 +0100
parent 8891:d9b7db6f140f
child 8913:560419b759c8
comparison
equal deleted inserted replaced
8911:cea6165a03d0 8912:43806beda970
475 function room_mt:handle_normal_presence(origin, stanza) 475 function room_mt:handle_normal_presence(origin, stanza)
476 local type = stanza.attr.type; 476 local type = stanza.attr.type;
477 local real_jid = stanza.attr.from; 477 local real_jid = stanza.attr.from;
478 local bare_jid = jid_bare(real_jid); 478 local bare_jid = jid_bare(real_jid);
479 local orig_occupant = self:get_occupant_by_real_jid(real_jid); 479 local orig_occupant = self:get_occupant_by_real_jid(real_jid);
480 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc");
480 local is_first_dest_session; 481 local is_first_dest_session;
481 local dest_occupant; 482 local dest_occupant;
482 if type == "unavailable" then 483 if type == "unavailable" then
483 if orig_occupant == nil then return true; end -- Unavailable from someone not in the room 484 if orig_occupant == nil then return true; end -- Unavailable from someone not in the room
484 -- dest_occupant = nil 485 -- dest_occupant = nil
502 local iter, ob, last = orig_occupant:each_session(); 503 local iter, ob, last = orig_occupant:each_session();
503 is_last_orig_session = iter(ob, iter(ob, last)) == nil; 504 is_last_orig_session = iter(ob, iter(ob, last)) == nil;
504 end 505 end
505 506
506 -- TODO Handle these cases sensibly 507 -- TODO Handle these cases sensibly
507 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc");
508 if orig_occupant == nil and not muc_x then 508 if orig_occupant == nil and not muc_x then
509 module:log("debug", "Join without <x>, possibly desynced"); 509 module:log("debug", "Join without <x>, possibly desynced");
510 elseif orig_occupant ~= nil and muc_x then 510 elseif orig_occupant ~= nil and muc_x then
511 module:log("debug", "Presence update with <x>, possibly desynced"); 511 module:log("debug", "Presence update with <x>, possibly desynced");
512 end 512 end