Diff

plugins/muc/muc.lib.lua @ 5196:a63c4ad6cb36

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Nov 2012 21:57:35 +0000
parent 5195:ce5d7538ac48
child 5241:4516e6bd51b4
line wrap: on
line diff
--- 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;