# HG changeset patch # User daurnimator # Date 1398790444 14400 # Node ID a58685df9d1610ec56e330a7ec0262643f4d3905 # Parent ee996e679f1532f02a87c4568c63b165a56df28b plugins/muc: Add room:has_occupant() method diff -r ee996e679f15 -r a58685df9d16 plugins/muc/mod_muc.lua --- a/plugins/muc/mod_muc.lua Mon Apr 28 16:31:21 2014 -0400 +++ b/plugins/muc/mod_muc.lua Tue Apr 29 12:54:04 2014 -0400 @@ -136,7 +136,7 @@ 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); diff -r ee996e679f15 -r a58685df9d16 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Mon Apr 28 16:31:21 2014 -0400 +++ b/plugins/muc/muc.lib.lua Tue Apr 29 12:54:04 2014 -0400 @@ -79,6 +79,10 @@ 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