Software / code / prosody
Comparison
plugins/muc/muc.lib.lua @ 4876:fa41d05ee7ef
muc.lib: room:set_historylength(): Condense code, and don't store length when equal to default
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 13 May 2012 22:58:25 +0100 |
| parent | 4875:f9fe28461101 |
| child | 4999:d5a3c5c1873c |
comparison
equal
deleted
inserted
replaced
| 4875:f9fe28461101 | 4876:fa41d05ee7ef |
|---|---|
| 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 if tonumber(length) == nil then | 342 length = math.min(tonumber(length) or default_history_length, self._data_max_history_length or math.huge); |
| 343 return | 343 if length == default_history_length then |
| 344 end | 344 length = nil; |
| 345 length = tonumber(length); | |
| 346 log("debug", "max_history_length %s", self._data.max_history_length or "nil"); | |
| 347 if self._data.max_history_length and length > self._data.max_history_length then | |
| 348 length = self._data.max_history_length | |
| 349 end | 345 end |
| 350 self._data.history_length = length; | 346 self._data.history_length = length; |
| 351 end | 347 end |
| 352 | 348 |
| 353 | 349 |