Software /
code /
prosody
Comparison
plugins/muc/muc.lib.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 | 5144:a30507061526 |
child | 5241:4516e6bd51b4 |
comparison
equal
deleted
inserted
replaced
5192:3fc3a3072cc2 | 5195:ce5d7538ac48 |
---|---|
22 local setmetatable = setmetatable; | 22 local setmetatable = setmetatable; |
23 local base64 = require "util.encodings".base64; | 23 local base64 = require "util.encodings".base64; |
24 local md5 = require "util.hashes".md5; | 24 local md5 = require "util.hashes".md5; |
25 | 25 |
26 local muc_domain = nil; --module:get_host(); | 26 local muc_domain = nil; --module:get_host(); |
27 local default_history_length = 20; | 27 local default_history_length, max_history_length = 20, math.huge; |
28 | 28 |
29 ------------ | 29 ------------ |
30 local function filter_xmlns_from_array(array, filters) | 30 local function filter_xmlns_from_array(array, filters) |
31 local count = 0; | 31 local count = 0; |
32 for i=#array,1,-1 do | 32 for i=#array,1,-1 do |
337 end | 337 end |
338 function room_mt:get_historylength() | 338 function room_mt:get_historylength() |
339 return self._data.history_length or default_history_length; | 339 return self._data.history_length or default_history_length; |
340 end | 340 end |
341 function room_mt:set_historylength(length) | 341 function room_mt:set_historylength(length) |
342 length = math.min(tonumber(length) or default_history_length, self._data_max_history_length or math.huge); | 342 length = math.min(tonumber(length) or default_history_length, max_history_length or math.huge); |
343 if length == default_history_length then | 343 if length == default_history_length then |
344 length = nil; | 344 length = nil; |
345 end | 345 end |
346 self._data.history_length = length; | 346 self._data.history_length = length; |
347 end | 347 end |
1148 jid = jid; | 1148 jid = jid; |
1149 _jid_nick = {}; | 1149 _jid_nick = {}; |
1150 _occupants = {}; | 1150 _occupants = {}; |
1151 _data = { | 1151 _data = { |
1152 whois = 'moderators'; | 1152 whois = 'moderators'; |
1153 history_length = (config and config.max_history_length) or default_history_length; | 1153 history_length = math.min((config and config.history_length) |
1154 max_history_length = (config and config.max_history_length) or default_history_length; | 1154 or default_history_length, max_history_length); |
1155 }; | 1155 }; |
1156 _affiliations = {}; | 1156 _affiliations = {}; |
1157 }, room_mt); | 1157 }, room_mt); |
1158 end | 1158 end |
1159 | 1159 |
1160 function _M.set_max_history_length(_max_history_length) | |
1161 max_history_length = _max_history_length or math.huge; | |
1162 end | |
1163 | |
1160 _M.room_mt = room_mt; | 1164 _M.room_mt = room_mt; |
1161 | 1165 |
1162 return _M; | 1166 return _M; |