diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-05-16 12:17:06 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-05-16 12:17:06 +0100 |
commit | 9ddd7d489e083c6cec5741bb9fdd359bed29b052 (patch) | |
tree | 52a605ff9f3f6bf9e1a6edc0da47664ad5e8d2c7 | |
parent | 98148f5e63f5111ac3d0d3c900c6b14dde2732b5 (diff) | |
download | prosody-9ddd7d489e083c6cec5741bb9fdd359bed29b052.tar.gz prosody-9ddd7d489e083c6cec5741bb9fdd359bed29b052.zip |
MUC: Allow the number of messages sent by default to be configured (fixes #397)
-rw-r--r-- | plugins/muc/muc.lib.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 77ac0b87..524cc843 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -171,7 +171,7 @@ function room_mt:send_history(to, stanza) if maxchars then maxchars = math.floor(maxchars); end local maxstanzas = math.floor(history_tag and tonumber(history_tag.attr.maxstanzas) or #history); - if not history_tag then maxstanzas = 20; end + if not history_tag then maxstanzas = self._data.default_history_messages; end local seconds = history_tag and tonumber(history_tag.attr.seconds); if seconds then seconds = datetime.datetime(os.time() - math.floor(seconds)); end @@ -359,6 +359,20 @@ function room_mt:set_historylength(length) self._data.history_length = length; end +-- Fix for clients who don't support XEP-0045 correctly +-- Default number of history messages the room returns +function room_mt:get_defaulthistorymessages() + return self._data.default_history_messages or default_history_length; +end +function room_mt:set_defaulthistorymessages(number) + number = math.min(tonumber(number) or default_history_length, self._data.history_length); + if number == default_history_length then + number = nil; + end + self._data.default_history_messages = number; +end + + local valid_whois = { moderators = true, anyone = true }; @@ -698,6 +712,12 @@ function room_mt:get_form_layout(actor) type = 'text-single', label = 'Maximum Number of History Messages Returned by Room', value = tostring(self:get_historylength()) + }, + { + name = 'muc#roomconfig_defaulthistorymessages', + type = 'text-single', + label = 'Default Number of History Messages Returned by Room', + value = tostring(self:get_defaulthistorymessages()) } }); return module:fire_event("muc-config-form", { room = self, actor = actor, form = form }) or form; @@ -746,6 +766,7 @@ function room_mt:process_form(origin, stanza) handle_option("public", "muc#roomconfig_publicroom"); handle_option("changesubject", "muc#roomconfig_changesubject"); handle_option("historylength", "muc#roomconfig_historylength"); + handle_option("defaulthistorymessages", "muc#roomconfig_defaulthistorymessages"); handle_option("whois", "muc#roomconfig_whois", valid_whois); handle_option("password", "muc#roomconfig_roomsecret"); |