Hi all - apologies for the double-email, I realized I didn't match the
Prosody style in my previous patch. This is essentially the same, just
with a clearer comment and with semicolons at the end of expressions.
Original description below:

When a user joins a MUC, and a pre-join hook changes their nickname -
it may have been changed into an existing occupant. When this occurs,
the room creates a new occupant, and an existing occupant winds up
being disassociated from the room.

This patch makes the room re-run the existing occupant check when a
nick change has occurred.

Apologies for the git formatting, I don't know mercurial very well - I
just downloaded the latest source, made a git repo, did my changes in
there, and exported as a patch. Hopefully it's easy to apply.

---
 plugins/muc/muc.lib.lua | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 01427db..9466e73 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -684,6 +684,16 @@ function room_mt:handle_normal_presence(origin, stanza)
     if module:fire_event(event_name, event) then return true; end

     local nick_changed = dest_occupant and orig_nick ~= dest_occupant.nick;
+    if nick_changed then
+        -- nick may now be an existing occupant
+        local orig_dest_occupant = dest_occupant;
+        dest_occupant = self:get_occupant_by_nick(dest_occupant.nick);
+        if dest_occupant then
+            is_first_dest_session = false;
+        else
+            dest_occupant = orig_dest_occupant;
+        end
+    end

     -- Check for nick conflicts
     if dest_occupant ~= nil and not is_first_dest_session
-- 
2.35.1

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prosody-dev/CACBMf33UyX8rSoQWBrVUuwbMjF8y9OymQAB9pn1anSwvLy3ynA%40mail.gmail.com.

Reply via email to