aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/mod_muc.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/mod_muc.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/mod_muc.lua')
-rw-r--r--plugins/muc/mod_muc.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index c0945daa..cef31298 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -31,6 +31,9 @@ local rooms = {};
local persistent_rooms = datamanager.load(nil, muc_host, "persistent") or {};
local component;
+-- Configurable options
+local max_history_messages = module:get_option_number("max_history_messages");
+
local function is_admin(jid)
return um_is_admin(jid) or um_is_admin(jid, module.host);
end
@@ -58,15 +61,20 @@ end
for jid in pairs(persistent_rooms) do
local node = jid_split(jid);
local data = datamanager.load(node, muc_host, "config") or {};
- local room = muc_new_room(jid);
+ local room = muc_new_room(jid, {
+ history_length = max_history_messages;
+ });
room._data = data._data;
+ room._data.history_length = max_history_messages; --TODO: Need to allow per-room with a global limit
room._affiliations = data._affiliations;
room.route_stanza = room_route_stanza;
room.save = room_save;
rooms[jid] = room;
end
-local host_room = muc_new_room(muc_host);
+local host_room = muc_new_room(muc_host, {
+ history_length = max_history_messages;
+});
host_room.route_stanza = room_route_stanza;
host_room.save = room_save;
@@ -113,7 +121,9 @@ component = register_component(muc_host, function(origin, stanza)
local room = rooms[bare];
if not room then
if not(restrict_room_creation) or is_admin(stanza.attr.from) then
- room = muc_new_room(bare);
+ room = muc_new_room(bare, {
+ history_length = max_history_messages;
+ });
room.route_stanza = room_route_stanza;
room.save = room_save;
rooms[bare] = room;