Comparison

plugins/muc/muc.lib.lua @ 10686:ac3ec4f2b124

MUC: Pass previous role to :publicise_occupant_status() when destroying a MUC
author Matthew Wild <mwild1@gmail.com>
date Thu, 12 Mar 2020 14:35:34 +0000
parent 10684:de607875d4bd
child 10687:8c2c5b4fde32
comparison
equal deleted inserted replaced
10685:98f21a155737 10686:ac3ec4f2b124
906 -- Removes everyone from the room 906 -- Removes everyone from the room
907 function room_mt:clear(x) 907 function room_mt:clear(x)
908 x = x or st.stanza("x", {xmlns='http://jabber.org/protocol/muc#user'}); 908 x = x or st.stanza("x", {xmlns='http://jabber.org/protocol/muc#user'});
909 local occupants_updated = {}; 909 local occupants_updated = {};
910 for nick, occupant in self:each_occupant() do -- luacheck: ignore 213 910 for nick, occupant in self:each_occupant() do -- luacheck: ignore 213
911 local prev_role = occupant.role;
911 occupant.role = nil; 912 occupant.role = nil;
912 self:save_occupant(occupant); 913 self:save_occupant(occupant);
913 occupants_updated[occupant] = true; 914 occupants_updated[occupant] = prev_role;
914 end 915 end
915 for occupant in pairs(occupants_updated) do 916 for occupant, prev_role in pairs(occupants_updated) do
916 self:publicise_occupant_status(occupant, x); 917 self:publicise_occupant_status(occupant, x, nil, nil, nil, prev_role);
917 module:fire_event("muc-occupant-left", { 918 module:fire_event("muc-occupant-left", {
918 room = self; 919 room = self;
919 nick = occupant.nick; 920 nick = occupant.nick;
920 occupant = occupant; 921 occupant = occupant;
921 }); 922 });