Diff

mod_muc_occupant_id/mod_muc_occupant_id.lua @ 3945:cf682a02b6d8

mod_muc_occupant_id: Handle MUC-PMs
author Maxime “pep” Buquet <pep@bouah.net>
date Sun, 15 Mar 2020 17:18:49 +0100
parent 3916:f1e28dcb3791
child 4010:ae27f3359df8
line wrap: on
line diff
--- a/mod_muc_occupant_id/mod_muc_occupant_id.lua	Wed Mar 11 20:09:17 2020 +0100
+++ b/mod_muc_occupant_id/mod_muc_occupant_id.lua	Sun Mar 15 17:18:49 2020 +0100
@@ -44,13 +44,24 @@
 	stanza:tag("occupant-id", { xmlns = xmlns_occupant_id, id = unique_id }):up();
 end
 
+local function muc_private(event)
+	local stanza, room = event.stanza, event.room;
+	local occupant = room._occupants[stanza.attr.from];
+
+	update_occupant({
+		stanza = stanza,
+		room = room,
+		occupant = occupant,
+	});
+end
+
 module:add_feature(xmlns_occupant_id);
 module:hook("muc-disco#info", function (event)
 	event.reply:tag("feature", { var = xmlns_occupant_id }):up();
 end);
 
--- 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);
+module:hook("muc-private-message", muc_private);