# HG changeset patch # User Kim Alvefur # Date 1415043453 -3600 # Node ID 814398c7139beb5ca2a405d5dead351686ad6d02 # Parent 57fb9ce21f9c6133a7846d11ee0c8ecef0a09f35 mod_muc_log: Add option to log rooms by default unless changed in room config diff -r 57fb9ce21f9c -r 814398c7139b mod_muc_log/mod_muc_log.lua --- a/mod_muc_log/mod_muc_log.lua Thu Oct 30 12:43:00 2014 +0100 +++ b/mod_muc_log/mod_muc_log.lua Mon Nov 03 20:37:33 2014 +0100 @@ -12,6 +12,7 @@ local datastore = "muc_log"; local muc_form_config_option = "muc#roomconfig_enablelogging" +local log_by_default = module:get_option_boolean("muc_log_by_default", false); local log_presences = module:get_option_boolean("muc_log_presences", true); -- Module Definitions @@ -33,6 +34,14 @@ end end +local function logging_enabled(room) + local enabled = room._data.logging; + if enabled == nil then + return log_by_default; + end + return enabled; +end + function log_if_needed(event) local stanza = event.stanza; @@ -56,7 +65,7 @@ if room._data.hidden then -- do not log any data of private rooms return; end - if not room._data.logging then -- do not log where logging is not enabled + if not logging_enabled(room) then -- do not log where logging is not enabled return; end @@ -129,7 +138,7 @@ name = muc_form_config_option, type = "boolean", label = "Enable Logging?", - value = room._data.logging or false, + value = logging_enabled(room), } ); end);