changeset 1311:27b2a357c73c

mod_mam_muc: porting archive checks from mod_mam (to avoid tracebacks about calling null functions)
author Vadim Misbakh-Soloviov <mva@mva.name>
date Wed, 19 Feb 2014 18:03:39 +0700
parents 2df312eb816d
children a48cf3ccdf9c
files mod_mam_muc/mod_mam_muc.lua
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_mam_muc/mod_mam_muc.lua	Wed Feb 19 17:59:17 2014 +0700
+++ b/mod_mam_muc/mod_mam_muc.lua	Wed Feb 19 18:03:39 2014 +0700
@@ -30,7 +30,16 @@
 local log_by_default = module:get_option_boolean("muc_log_by_default", true);
 local advertise_archive = module:get_option_boolean("muc_log_advertise", true);
 
-local archive = module:open_store("archive2", "archive");
+local archive_store = "archive2";
+local archive = module:open_store(archive_store, "archive");
+if not archive then
+        module:log("error", "Could not open archive storage");
+        return
+elseif not archive.find then
+        module:log("error", "mod_%s does not support archiving, switch to mod_storage_sql2", archive._provided_by);
+        return
+end
+
 local rooms = hosts[module.host].modules.muc.rooms;
 
 if not log_all_rooms then