Comparison

plugins/muc/muc.lib.lua @ 8914:e9acb928c637

MUC: Remove support for GC 1.0 for joining
author Kim Alvefur <zash@zash.se>
date Fri, 09 Mar 2018 19:03:50 +0100
parent 8913:560419b759c8
child 8915:2502be210a85
comparison
equal deleted inserted replaced
8913:560419b759c8 8914:e9acb928c637
468 local type = stanza.attr.type; 468 local type = stanza.attr.type;
469 local real_jid = stanza.attr.from; 469 local real_jid = stanza.attr.from;
470 local bare_jid = jid_bare(real_jid); 470 local bare_jid = jid_bare(real_jid);
471 local orig_occupant = self:get_occupant_by_real_jid(real_jid); 471 local orig_occupant = self:get_occupant_by_real_jid(real_jid);
472 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); 472 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc");
473
474 if orig_occupant == nil and not muc_x then
475 module:log("debug", "Attempted join without <x>, possibly desynced");
476 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "You must join the room before sending presence updates"));
477 return true;
478 end
479
473 local is_first_dest_session; 480 local is_first_dest_session;
474 local dest_occupant; 481 local dest_occupant;
475 if type == "unavailable" then 482 if type == "unavailable" then
476 if orig_occupant == nil then return true; end -- Unavailable from someone not in the room 483 if orig_occupant == nil then return true; end -- Unavailable from someone not in the room
477 -- dest_occupant = nil 484 -- dest_occupant = nil
494 -- Is there are least 2 sessions? 501 -- Is there are least 2 sessions?
495 local iter, ob, last = orig_occupant:each_session(); 502 local iter, ob, last = orig_occupant:each_session();
496 is_last_orig_session = iter(ob, iter(ob, last)) == nil; 503 is_last_orig_session = iter(ob, iter(ob, last)) == nil;
497 end 504 end
498 505
499 -- TODO Handle these cases sensibly
500 if orig_occupant == nil and not muc_x then
501 module:log("debug", "Join without <x>, possibly desynced");
502 elseif orig_occupant ~= nil and muc_x then
503 module:log("debug", "Presence update with <x>, possibly desynced");
504 end
505
506 local orig_nick = dest_occupant and dest_occupant.nick; 506 local orig_nick = dest_occupant and dest_occupant.nick;
507 507
508 local event, event_name = { 508 local event, event_name = {
509 room = self; 509 room = self;
510 origin = origin; 510 origin = origin;
602 dest_x:tag("status", {code = "100"}):up(); 602 dest_x:tag("status", {code = "100"}):up();
603 end 603 end
604 self:save_occupant(dest_occupant); 604 self:save_occupant(dest_occupant);
605 605
606 if orig_occupant == nil or muc_x then 606 if orig_occupant == nil or muc_x then
607 -- Send occupant list to newly joined user 607 -- Send occupant list to newly joined or desynced user
608 self:send_occupant_list(real_jid, function(nick, occupant) -- luacheck: ignore 212 608 self:send_occupant_list(real_jid, function(nick, occupant) -- luacheck: ignore 212
609 -- Don't include self 609 -- Don't include self
610 return occupant:get_presence(real_jid) == nil; 610 return occupant:get_presence(real_jid) == nil;
611 end) 611 end)
612 end 612 end