Comparison

plugins/muc/muc.lib.lua @ 6231:bc12a8253f94

plugins/muc/muc.lib: Move sending of occupant list to joining user out of hook, and into main flow: It has to occur before publication of their status
author daurnimator <quae@daurnimator.com>
date Mon, 21 Apr 2014 17:51:32 -0400
parent 6229:8aa59b73f801
child 6232:d7dc71d9171d
child 6237:a58685df9d16
comparison
equal deleted inserted replaced
6230:97d53caef325 6231:bc12a8253f94
317 reply.tags[1].attr.code = "403"; 317 reply.tags[1].attr.code = "403";
318 event.origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"})); 318 event.origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"}));
319 return true; 319 return true;
320 end 320 end
321 end, -10); 321 end, -10);
322
323 -- Send occupant list to newly joined user
324 module:hook("muc-occupant-joined", function(event)
325 local real_jid = event.stanza.attr.from;
326 event.room:send_occupant_list(real_jid, function(nick, occupant)
327 -- Don't include self
328 return occupant:get_presence(real_jid) == nil;
329 end);
330 end, 80);
331 322
332 function room_mt:handle_presence_to_occupant(origin, stanza) 323 function room_mt:handle_presence_to_occupant(origin, stanza)
333 local type = stanza.attr.type; 324 local type = stanza.attr.type;
334 if type == "error" then -- error, kick em out! 325 if type == "error" then -- error, kick em out!
335 return self:handle_kickable(origin, stanza) 326 return self:handle_kickable(origin, stanza)
455 end 446 end
456 if orig_occupant == nil and self:get_whois() == "anyone" then 447 if orig_occupant == nil and self:get_whois() == "anyone" then
457 dest_x:tag("status", {code = "100"}):up(); 448 dest_x:tag("status", {code = "100"}):up();
458 end 449 end
459 self:save_occupant(dest_occupant); 450 self:save_occupant(dest_occupant);
451
452 if orig_occupant == nil and is_first_dest_session then
453 -- Send occupant list to newly joined user
454 self:send_occupant_list(real_jid, function(nick, occupant)
455 -- Don't include self
456 return occupant:get_presence(real_jid) == nil;
457 end)
458 end
460 self:publicise_occupant_status(dest_occupant, dest_x); 459 self:publicise_occupant_status(dest_occupant, dest_x);
461 460
462 if orig_occupant ~= nil and orig_occupant ~= dest_occupant and not is_last_orig_session then -- If user is swapping and wasn't last original session 461 if orig_occupant ~= nil and orig_occupant ~= dest_occupant and not is_last_orig_session then -- If user is swapping and wasn't last original session
463 log("debug", "session %s split nicks; showing %s rejoining", real_jid, orig_occupant.nick); 462 log("debug", "session %s split nicks; showing %s rejoining", real_jid, orig_occupant.nick);
464 -- Show the original nick joining again 463 -- Show the original nick joining again