Software /
code /
prosody
Changeset
5196:a63c4ad6cb36
Merge 0.9->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 22 Nov 2012 21:57:35 +0000 |
parents | 5194:9dca5bd5c2be (current diff) 5195:ce5d7538ac48 (diff) |
children | 5199:e6fedce399eb 5205:f7ff48494c2b |
files | |
diffstat | 2 files changed, 12 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua Thu Nov 22 21:02:27 2012 +0000 +++ b/plugins/muc/mod_muc.lua Thu Nov 22 21:57:35 2012 +0000 @@ -37,7 +37,7 @@ 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 @@ 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 @@ 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 @@ 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;
--- a/plugins/muc/muc.lib.lua Thu Nov 22 21:02:27 2012 +0000 +++ b/plugins/muc/muc.lib.lua Thu Nov 22 21:57:35 2012 +0000 @@ -24,7 +24,7 @@ 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 @@ 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 @@ _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;