MUC: Send participant list and subject on explicit joins (thanks daurnimator)
[prosody.git] / plugins / muc / muc.lib.lua
index 238cd3e1b57741c7d53241b9ac1a3775b80aa93d..baa72a56f6da07648e8445581737c86377942797 100644 (file)
@@ -531,10 +531,10 @@ function room_mt:handle_normal_presence(origin, stanza)
                        if not is_first_dest_session then -- User is swapping into another pre-existing session
                                log("debug", "session %s is swapping into multisession %s, showing it leave.", real_jid, dest_occupant.nick);
                                -- Show the other session leaving
-                               local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";})
-                                       :tag("status"):text("you are joining pre-existing session " .. dest_nick):up();
+                               local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";});
                                add_item(x, self:get_affiliation(bare_jid), "none");
                                local pr = st.presence{from = dest_occupant.nick, to = real_jid, type = "unavailable"}
+                                       :tag("status"):text("you are joining pre-existing session " .. dest_nick):up()
                                        :add_child(x);
                                self:route_stanza(pr);
                        end
@@ -577,7 +577,7 @@ function room_mt:handle_normal_presence(origin, stanza)
                end
                self:save_occupant(dest_occupant);
 
-               if orig_occupant == nil then
+               if orig_occupant == nil or muc_x then
                        -- Send occupant list to newly joined user
                        self:send_occupant_list(real_jid, function(nick, occupant) -- luacheck: ignore 212
                                -- Don't include self
@@ -598,7 +598,7 @@ function room_mt:handle_normal_presence(origin, stanza)
                        self:route_stanza(pr);
                end
 
-               if orig_occupant == nil then
+               if orig_occupant == nil or muc_x then
                        if is_first_dest_session then
                                module:fire_event("muc-occupant-joined", {
                                        room = self;