Software /
code /
prosody
Diff
plugins/muc/mod_muc.lua @ 5195:ce5d7538ac48
muc: Make max_history_messages simply a service-wide config option, and don't store it per-room (rooms still have their own history_message, but this is a global limit)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 22 Nov 2012 21:57:06 +0000 |
parent | 5074:a87afeea8b48 |
child | 5210:862a6fae05e7 |
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua Thu Nov 22 20:59:20 2012 +0000 +++ b/plugins/muc/mod_muc.lua Thu Nov 22 21:57:06 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;