mod_mam_muc: Warn if the storage driver is missing the deletion API (instead of a traceback) (thanks asterix)
authorKim Alvefur <zash@zash.se>
Sat, 18 Nov 2017 13:55:47 +0100
changeset 2839 b69ef062806e
parent 2838 3fb5f173f213
child 2840 52a7c0f6aea1
mod_mam_muc: Warn if the storage driver is missing the deletion API (instead of a traceback) (thanks asterix)
mod_mam_muc/mod_mam_muc.lua
--- a/mod_mam_muc/mod_mam_muc.lua	Sat Nov 18 01:01:59 2017 +0100
+++ b/mod_mam_muc/mod_mam_muc.lua	Sat Nov 18 13:55:47 2017 +0100
@@ -439,10 +439,15 @@
 	end);
 end
 
-module:hook("muc-room-destroyed", function(event)
-	local room_node = jid_split(event.room.jid);
-	archive:delete(room_node);
-end);
+if not archive.delete then
+	module:log("warn", "Storage driver %s does not support deletion", archive._provided_by);
+	module:log("warn", "Archived message will persist after a room has been destroyed");
+else
+	module:hook("muc-room-destroyed", function(event)
+		local room_node = jid_split(event.room.jid);
+		archive:delete(room_node);
+	end);
+end
 
 -- And role/affiliation changes?