mod_muc: Add muc-add-history event to allow modules to override default history storage
authorMatthew Wild <mwild1@gmail.com>
Tue, 06 Jan 2015 19:33:25 +0000
changeset 6538 0f940a7ba489
parent 6537 b89406fa076c
child 6539 605a87e90e27
mod_muc: Add muc-add-history event to allow modules to override default history storage
plugins/muc/history.lib.lua
--- a/plugins/muc/history.lib.lua	Tue Dec 16 18:33:54 2014 -0500
+++ b/plugins/muc/history.lib.lua	Tue Jan 06 19:33:25 2015 +0000
@@ -135,7 +135,7 @@
 end, 50); -- Before subject(20)
 
 -- add to history
-module:hook("muc-broadcast-message", function(event)
+module:hook("muc-add-history", function(event)
 	local historic = event.stanza:get_child("body");
 	if historic then
 		local room = event.room
@@ -151,6 +151,13 @@
 		table.insert(history, entry);
 		while #history > get_historylength(room) do table.remove(history, 1) end
 	end
+	return true;
+end, -1);
+
+-- Have a single muc-add-history event, so that plugins can mark it
+-- as handled without stopping other muc-broadcast-message handlers
+module:hook("muc-broadcast-message", function(event)
+	module:fire_event("muc-add-history", event);
 end);
 
 return {