diff options
author | Kim Alvefur <zash@zash.se> | 2016-05-07 17:22:58 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-05-07 17:22:58 +0200 |
commit | 89ac539d01e44a52401c011025b2449998a23e22 (patch) | |
tree | dda704f84fc52d0ef5609db6dc0cf9bf638bda73 /plugins/muc | |
parent | 32be089091c4303c5dabccefcfdf8e38cf6d6366 (diff) | |
download | prosody-89ac539d01e44a52401c011025b2449998a23e22.tar.gz prosody-89ac539d01e44a52401c011025b2449998a23e22.zip |
MUC: Treat explicit join presence as join
Diffstat (limited to 'plugins/muc')
-rw-r--r-- | plugins/muc/muc.lib.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index eb992aa3..71f199dd 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -446,6 +446,7 @@ end function room_mt:handle_normal_presence(origin, stanza) local type = stanza.attr.type; + local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); local real_jid = stanza.attr.from; local bare_jid = jid_bare(real_jid); local orig_occupant = self:get_occupant_by_real_jid(real_jid); @@ -455,13 +456,18 @@ function room_mt:handle_normal_presence(origin, stanza) if type == "unavailable" then -- luacheck: ignore 542 -- FIXME Why the empty if branch? -- dest_occupant = nil - elseif orig_occupant and orig_occupant.nick == stanza.attr.to then -- Just a presence update + elseif orig_occupant and not muc_x and orig_occupant.nick == stanza.attr.to then -- Just a presence update log("debug", "presence update for %s from session %s", orig_occupant.nick, real_jid); dest_occupant = orig_occupant; else local dest_jid = stanza.attr.to; dest_occupant = self:get_occupant_by_nick(dest_jid); - if dest_occupant == nil then + if muc_x then + dest_occupant = self:new_occupant(bare_jid, dest_jid); + if dest_occupant == nil then + is_first_dest_session = true; + end + elseif dest_occupant == nil then log("debug", "no occupant found for %s; creating new occupant object for %s", dest_jid, real_jid); is_first_dest_session = true; dest_occupant = self:new_occupant(bare_jid, dest_jid); @@ -477,7 +483,6 @@ function room_mt:handle_normal_presence(origin, stanza) end -- TODO Handle these cases sensibly - local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); if orig_occupant == nil and not muc_x then module:log("debug", "Join without <x>, possibly desynced"); elseif orig_occupant ~= nil and muc_x then |