diff options
author | daurnimator <quae@daurnimator.com> | 2014-04-29 12:54:04 -0400 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2014-04-29 12:54:04 -0400 |
commit | 51e7021e0ce200dc4dd2b8e2d5b91b4b9625c945 (patch) | |
tree | 2cbf503c4f484dc91927f0c718eea34913c6bb31 | |
parent | c34f4b0ae3b32f17ad4ccffbf6356d593e4128d2 (diff) | |
download | prosody-51e7021e0ce200dc4dd2b8e2d5b91b4b9625c945.tar.gz prosody-51e7021e0ce200dc4dd2b8e2d5b91b4b9625c945.zip |
plugins/muc: Add room:has_occupant() method
-rw-r--r-- | plugins/muc/mod_muc.lua | 2 | ||||
-rw-r--r-- | plugins/muc/muc.lib.lua | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index ecc136f1..f0458e16 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -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); diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 6aca5c62..7c039ce3 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -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 |