Diff

plugins/muc/muc.lib.lua @ 8481:d546815e555e

MUC: Move delayed delivery check into an event handler
author Kim Alvefur <zash@zash.se>
date Thu, 21 Dec 2017 13:38:59 +0100
parent 8480:3d3706147174
child 8482:8b2219011386
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Fri Dec 22 01:02:05 2017 +0100
+++ b/plugins/muc/muc.lib.lua	Thu Dec 21 13:38:59 2017 +0100
@@ -164,6 +164,16 @@
 end
 
 function room_mt:broadcast_message(stanza)
+	if module:fire_event("muc-broadcast-message", {room = self, stanza = stanza}) then
+		return true;
+	end
+	self:broadcast(stanza);
+	return true;
+end
+
+-- Strip delay tags claiming to be from us
+module:hook("muc-broadcast-message", function (event)
+	local stanza = event.stanza;
 	local to = stanza.attr.to;
 	local room_jid = self.jid;
 
@@ -180,13 +190,7 @@
 		end
 		return child;
 	end)
-
-	if module:fire_event("muc-broadcast-message", {room = self, stanza = stanza}) then
-		return true;
-	end
-	self:broadcast(stanza);
-	return true;
-end
+end);
 
 -- Broadcast a stanza to all occupants in the room.
 -- optionally checks conditional called with (nick, occupant)