aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-09-11 14:54:16 +0200
committerKim Alvefur <zash@zash.se>2016-09-11 14:54:16 +0200
commit804406e5f8ae306cbb5770c38720c09cbb6c43c1 (patch)
tree96f8bf5934466a421837e5f8933070a6cc103b6c /plugins
parentbe23c86153168e94b567f6d6a5da9bf282f7b9b7 (diff)
downloadprosody-804406e5f8ae306cbb5770c38720c09cbb6c43c1.tar.gz
prosody-804406e5f8ae306cbb5770c38720c09cbb6c43c1.zip
MUC: Fix conflict when restoring room where the same bare JID has joined as multiple participants
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/muc.lib.lua35
1 files changed, 10 insertions, 25 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index b50964d2..1e433db0 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1356,7 +1356,6 @@ function _M.restore_room(frozen, state)
end
local occupants = {};
- local occupant_sessions = {};
local room_name, room_host = jid_split(room_jid);
if frozen.jid and frozen._affiliations then
@@ -1375,33 +1374,19 @@ function _M.restore_room(frozen, state)
if node or host:sub(1,1) ~= "_" then
if host == room_host and node == room_name and resource and type(data) == "table" then
-- full room jid: bare real jid and role
- local bare_jid = data.bare_jid;
- local occupant = occupant_lib.new(bare_jid, jid);
- occupant.jid = data.jid;
+ local nick = jid;
+ local occupant = occupants[nick] or occupant_lib.new(data.bare_jid, nick);
+ occupant.bare_jid = data.bare_jid;
occupant.role = data.role;
- occupants[bare_jid] = occupant;
- local sessions = occupant_sessions[bare_jid];
- if sessions then
- for full_jid, presence in pairs(sessions) do
- occupant:set_session(full_jid, presence);
- end
- end
- occupant_sessions[bare_jid] = nil;
- elseif type(data) == "table" and data.name then
+ occupant.jid = data.jid; -- Primary session JID
+ occupants[nick] = occupant;
+ elseif type(data) == "table" and data.name == "presence" then
-- full user jid: presence
+ local nick = data.attr.from;
+ local occupant = occupants[nick] or occupant_lib.new(nil, nick);
local presence = st.deserialize(data);
- local bare_jid = jid_bare(jid);
- local occupant = occupants[bare_jid];
- local sessions = occupant_sessions[bare_jid];
- if occupant then
- occupant:set_session(jid, presence);
- elseif sessions then
- sessions[jid] = presence;
- else
- occupant_sessions[bare_jid] = {
- [jid] = presence;
- };
- end
+ occupant:set_session(jid, presence);
+ occupants[nick] = occupant;
end
end
end