aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/mod_muc.lua15
-rw-r--r--plugins/muc/muc.lib.lua12
2 files changed, 12 insertions, 15 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index 0f275196..bf29d1ca 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -37,7 +37,7 @@ local rooms = rooms;
local persistent_rooms = datamanager.load(nil, muc_host, "persistent") or {};
-- Configurable options
-local max_history_messages = module:get_option_number("max_history_messages");
+muclib.set_max_history_length(module:get_option_number("max_history_messages"));
local function is_admin(jid)
return um_is_admin(jid, module.host);
@@ -82,11 +82,8 @@ for jid in pairs(persistent_rooms) do
local node = jid_split(jid);
local data = datamanager.load(node, muc_host, "config");
if data then
- local room = muc_new_room(jid, {
- max_history_length = max_history_messages;
- });
+ local room = muc_new_room(jid);
room._data = data._data;
- room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings
room._affiliations = data._affiliations;
room.route_stanza = room_route_stanza;
room.save = room_save;
@@ -99,9 +96,7 @@ for jid in pairs(persistent_rooms) do
end
if persistent_errors then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end
-local host_room = muc_new_room(muc_host, {
- max_history_length = max_history_messages;
-});
+local host_room = muc_new_room(muc_host);
host_room.route_stanza = room_route_stanza;
host_room.save = room_save;
@@ -154,9 +149,7 @@ function stanza_handler(event)
if not(restrict_room_creation) or
(restrict_room_creation == "admin" and is_admin(stanza.attr.from)) or
(restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then
- room = muc_new_room(bare, {
- max_history_length = max_history_messages;
- });
+ room = muc_new_room(bare);
room.route_stanza = room_route_stanza;
room.save = room_save;
rooms[bare] = room;
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 6ba7b621..c5be3a91 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -24,7 +24,7 @@ local base64 = require "util.encodings".base64;
local md5 = require "util.hashes".md5;
local muc_domain = nil; --module:get_host();
-local default_history_length = 20;
+local default_history_length, max_history_length = 20, math.huge;
------------
local function filter_xmlns_from_array(array, filters)
@@ -339,7 +339,7 @@ function room_mt:get_historylength()
return self._data.history_length or default_history_length;
end
function room_mt:set_historylength(length)
- length = math.min(tonumber(length) or default_history_length, self._data_max_history_length or math.huge);
+ length = math.min(tonumber(length) or default_history_length, max_history_length or math.huge);
if length == default_history_length then
length = nil;
end
@@ -1150,13 +1150,17 @@ function _M.new_room(jid, config)
_occupants = {};
_data = {
whois = 'moderators';
- history_length = (config and config.max_history_length) or default_history_length;
- max_history_length = (config and config.max_history_length) or default_history_length;
+ history_length = math.min((config and config.history_length)
+ or default_history_length, max_history_length);
};
_affiliations = {};
}, room_mt);
end
+function _M.set_max_history_length(_max_history_length)
+ max_history_length = _max_history_length or math.huge;
+end
+
_M.room_mt = room_mt;
return _M;