Changeset

4335:e03dadd4f2d1

mod_muc_rai: Get user JID from event.occupant `event.stanza` isn't always available.
author JC Brand <jc@opkode.com>
date Wed, 13 Jan 2021 16:23:44 +0100
parents 4334:d90ce7dc3f88
children 4336:6872e55cfb92
files mod_muc_rai/mod_muc_rai.lua
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_rai/mod_muc_rai.lua	Wed Jan 13 15:02:27 2021 +0000
+++ b/mod_muc_rai/mod_muc_rai.lua	Wed Jan 13 16:23:44 2021 +0100
@@ -186,6 +186,14 @@
 	return rooms_with_activity;
 end
 
+--- FIXME:
+-- The subscribe/unsubscribe code below doesn't work in the case where
+-- the user joins from multiple resources with the same nick.
+--
+-- For example, resource A joining, followed by resource B joining, followed
+-- by A leaving and B leaving will ultimately trigger muc-occupant-joined for
+-- resource A and muc-occupant-left for resource B.
+
 module:hook("muc-occupant-joined", function(event)
 	local room_jid, user_jid = event.room.jid, event.stanza.attr.from;
 	local ok, _ = unsubscribe_room(user_jid, room_jid);
@@ -195,7 +203,7 @@
 end);
 
 module:hook("muc-occupant-left", function(event)
-	local room_jid, user_jid = event.room.jid, event.stanza.attr.from;
+	local room_jid, user_jid = event.room.jid, event.occupant.jid;
 	local ok, _ = subscribe_room(user_jid, room_jid);
 	if ok then
 		module:log("debug", "Subscribed %s to %s Reason: muc-occupant-left", user_jid, room_jid)