aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/muc.lib.lua
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-05-19 13:40:54 -0400
committerdaurnimator <quae@daurnimator.com>2014-05-19 13:40:54 -0400
commit0d12eda7d73df356c24e9db0e7d3899962a1ce87 (patch)
tree0fe9a7ab332223c0f9165bd1f6d5ed90a3b0e51e /plugins/muc/muc.lib.lua
parent4cc91481bf8eaa34ba1d5350dcd1119e7b45f8a7 (diff)
downloadprosody-0d12eda7d73df356c24e9db0e7d3899962a1ce87.tar.gz
prosody-0d12eda7d73df356c24e9db0e7d3899962a1ce87.zip
plugins/muc/muc: Better check for live sessions
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r--plugins/muc/muc.lib.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index df823180..5838cbe9 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -100,11 +100,21 @@ function room_mt:save_occupant(occupant)
self._jid_nick[real_jid] = nil;
end
end
- if occupant.role ~= nil and next(occupant.sessions) then
+
+ local has_live_session = false
+ if occupant.role ~= nil then
for real_jid, presence in occupant:each_session() do
- self._jid_nick[real_jid] = occupant.nick;
+ if presence.attr.type == nil then
+ has_live_session = true
+ self._jid_nick[real_jid] = occupant.nick;
+ end
end
- else
+ if not has_live_session then
+ -- Has no live sessions left; they have left the room.
+ occupant.role = nil
+ end
+ end
+ if not has_live_session then
occupant = nil
end
self._occupants[id] = occupant