aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/muc.lib.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-07-06 17:09:23 +0100
committerMatthew Wild <mwild1@gmail.com>2010-07-06 17:09:23 +0100
commitddd99927a2db1f9dddd6a42e936114a9a9174a31 (patch)
tree4ae4dcf843bc7a250079717640000f7e1d458862 /plugins/muc/muc.lib.lua
parent56c310f30c0bc9af0bc394719a1960e37677fb6e (diff)
downloadprosody-ddd99927a2db1f9dddd6a42e936114a9a9174a31.tar.gz
prosody-ddd99927a2db1f9dddd6a42e936114a9a9174a31.zip
MUC: Make number of stored history messages configurable with option max_history_messages (thanks michal and others who requested)
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r--plugins/muc/muc.lib.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 6dfc6bb9..ab129287 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 history_length = 20;
+local default_history_length = 20;
------------
local function filter_xmlns_from_array(array, filters)
@@ -136,7 +136,7 @@ function room_mt:broadcast_message(stanza, historic)
stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
local entry = { stanza = stanza, stamp = stamp };
t_insert(history, entry);
- while #history > history_length do t_remove(history, 1) end
+ while #history > self._data.history_length do t_remove(history, 1) end
end
end
function room_mt:broadcast_except_nick(stanza, nick)
@@ -972,13 +972,14 @@ end
local _M = {}; -- module "muc"
-function _M.new_room(jid)
+function _M.new_room(jid, config)
return setmetatable({
jid = jid;
_jid_nick = {};
_occupants = {};
_data = {
- whois = 'moderators',
+ whois = 'moderators';
+ history_length = (config and config.history_length) or default_history_length;
};
_affiliations = {};
}, room_mt);