mod_muc: add muc-private-message event
authorMaxime “pep” Buquet <pep@bouah.net>
Mon, 24 Feb 2020 14:16:45 +0100
changeset 10666 46373b97e648
parent 10665 4eee1aaa9405
child 10667 fd651ba2317f
mod_muc: add muc-private-message event This seems to be the one place handling MUC-PMs. This event is added so that plugins (such as muc_occupant_id) can edit them without having to redo the work.
plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Mon Feb 24 09:10:28 2020 +0100
+++ b/plugins/muc/muc.lib.lua	Mon Feb 24 14:16:45 2020 +0100
@@ -814,7 +814,9 @@
 	stanza = muc_util.filter_muc_x(st.clone(stanza));
 	stanza:tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }):up();
 	stanza.attr.from = current_nick;
-	self:route_to_occupant(o_data, stanza)
+	if module:fire_event("muc-private-message", { room = self, origin = origin, stanza = stanza }) ~= false then
+		self:route_to_occupant(o_data, stanza)
+	end
 	-- TODO: Remove x tag?
 	stanza.attr.from = from;
 	return true;