Changeset

3916:f1e28dcb3791

mod_muc_occupant_id: Ensure id is added to self-presences, nick changes, etc.
author Maxime “pep” Buquet <pep@bouah.net>
date Thu, 27 Feb 2020 00:39:40 +0100
parents 3915:80dffbbd056b
children 3917:3e19c25ff93e
files mod_muc_occupant_id/README.markdown mod_muc_occupant_id/mod_muc_occupant_id.lua
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_occupant_id/README.markdown	Wed Feb 26 22:48:10 2020 +0000
+++ b/mod_muc_occupant_id/README.markdown	Thu Feb 27 00:39:40 2020 +0100
@@ -13,7 +13,6 @@
 TODO
 ====
 
-- Self-presence
 - Subject messages
 - MUC-PM support
 
--- a/mod_muc_occupant_id/mod_muc_occupant_id.lua	Wed Feb 26 22:48:10 2020 +0000
+++ b/mod_muc_occupant_id/mod_muc_occupant_id.lua	Thu Feb 27 00:39:40 2020 +0100
@@ -30,7 +30,12 @@
 end
 
 local function update_occupant(event)
-	local stanza, occupant, room = event.stanza, event.occupant, event.room;
+	local stanza, room, occupant, dest_occupant = event.stanza, event.room, event.occupant, event.dest_occupant;
+
+	-- "muc-occupant-pre-change" provides "dest_occupant" but not "occupant".
+	if dest_occupant ~= nil then
+		occupant = dest_occupant;
+	end
 
 	-- strip any existing <occupant-id/> tags to avoid forgery
 	stanza:remove_children("occupant-id", xmlns_occupant_id);
@@ -47,4 +52,5 @@
 -- TODO: Handle MUC-PMs
 module:hook("muc-broadcast-presence", update_occupant);
 module:hook("muc-occupant-pre-join", update_occupant);
+module:hook("muc-occupant-pre-change", update_occupant);
 module:hook("muc-occupant-groupchat", update_occupant);