plugins/muc: Add room:has_occupant() method
authordaurnimator <quae@daurnimator.com>
Tue, 29 Apr 2014 16:54:04 +0000 (12:54 -0400)
committerdaurnimator <quae@daurnimator.com>
Tue, 29 Apr 2014 16:54:04 +0000 (12:54 -0400)
plugins/muc/mod_muc.lua
plugins/muc/muc.lib.lua

index ecc136f10528d9635b33eab78bb261a57ecdd14f..f0458e16cd53ad1e795b8e6748c6cd973c14e005 100644 (file)
@@ -136,7 +136,7 @@ end)
 
 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);
index 6aca5c62431fb25dd1358dbddec3affeb2b3ce3c..7c039ce30ccdd959b999dbb7a7daa415d08316cb 100644 (file)
@@ -79,6 +79,10 @@ do
        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