diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-09-25 12:39:28 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-09-25 12:39:28 +0500 |
commit | 02cc8144246e44d0ef272b57e50abf68951b7010 (patch) | |
tree | ceeb0ff3aa67c5b4c0ecc8bd07cb79d89a0b2dba /plugins/muc/muc.lib.lua | |
parent | 9547770360bcec49cd8959c183deeb02538e57ac (diff) | |
download | prosody-02cc8144246e44d0ef272b57e50abf68951b7010.tar.gz prosody-02cc8144246e44d0ef272b57e50abf68951b7010.zip |
MUC: Added multi-session support to the room-exiting occupant use case.
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r-- | plugins/muc/muc.lib.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 9a3e720f..35bde4c6 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -215,10 +215,22 @@ function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc elseif type == "unavailable" then -- unavailable if current_nick then log("debug", "%s leaving %s", current_nick, room); - local data = self._occupants[current_nick]; - data.role = 'none'; - self:broadcast_presence(pr); - self._occupants[current_nick] = nil; + local occupant = self._occupants[current_nick]; + local old_session = occupant.sessions[from]; + local new_jid = next(occupant.sessions); + if new_jid == from then new_jid = next(occupant.sessions, new_jid); end + if new_jid then + occupant.jid = new_jid; + occupant.sessions[from] = nil; + local pr = st.clone(occupant[new_jid]) + :tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) + :tag("item", {affiliation=occupant.affiliation, role=occupant.role}); + self:broadcast_except_nick(pr, current_nick); + else + occupant.role = 'none'; + self:broadcast_presence(pr); + self._occupants[current_nick] = nil; + end self._jid_nick[from] = nil; end elseif not type then -- available |