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 }); |