module:hook("muc-occupant-left",function(event)
local room = event.room
- if not next(room._occupants) and not persistent.get(room) then -- empty, non-persistent room
+ if not room:has_occupant() and not persistent.get(room) then -- empty, non-persistent room
module:fire_event("muc-room-destroyed", { room = room });
end
end);
end
end
+function room_mt:has_occupant()
+ return next(self._occupants, nil) ~= nil
+end
+
function room_mt:get_occupant_by_real_jid(real_jid)
local occupant_jid = self:get_occupant_jid(real_jid);
if occupant_jid == nil then return nil end