Software /
code /
prosody
Changeset
8794:0e2c1c4d4f78
Merge 0.10 -> trunk
This commit intentionally drops changes from c2b99fa134b3
and 8da11142fabf which are based on older MUC code.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 16 May 2018 23:50:08 +0100 |
parents | 8788:7a9b680a79fb (current diff) 8793:05a3275b6873 (diff) |
children | 8796:51375b007239 |
files | plugins/mod_websocket.lua plugins/muc/history.lib.lua plugins/muc/muc.lib.lua |
diffstat | 3 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri May 04 00:10:17 2018 +0200 +++ b/.hgtags Wed May 16 23:50:08 2018 +0100 @@ -62,3 +62,4 @@ 2a7b52437167a5c7b6c8a5bc79f4463afe092fd5 0.9.12 39966cbc29f46d7ae9660edca8683d5121c82edf 0.10.0 082d127286451eb55420c36424dd321e8d9bceee 0.9.13 +4ae8dd415e9431924ad4aa0b57bcee8a4a9272f8 0.10.1
--- a/plugins/mod_websocket.lua Fri May 04 00:10:17 2018 +0200 +++ b/plugins/mod_websocket.lua Wed May 16 23:50:08 2018 +0100 @@ -261,6 +261,7 @@ session.ip = request.ip; session.secure = consider_websocket_secure or session.secure; + session.websocket_request = request; session.open_stream = session_open_stream; session.close = session_close;
--- a/plugins/muc/history.lib.lua Fri May 04 00:10:17 2018 +0200 +++ b/plugins/muc/history.lib.lua Wed May 16 23:50:08 2018 +0100 @@ -31,6 +31,19 @@ return true; end +-- Fix for clients who don't support XEP-0045 correctly +-- Default number of history messages the room returns +local function get_defaulthistorymessages(room) + return room._data.default_history_messages or default_history_length; +end +local function set_defaulthistorymessages(room, number) + number = math.min(tonumber(number) or default_history_length, room._data.history_length or default_history_length); + if number == default_history_length then + number = nil; + end + room._data.default_history_messages = number; +end + module:hook("muc-config-form", function(event) table.insert(event.form, { name = "muc#roomconfig_historylength"; @@ -38,6 +51,12 @@ label = "Maximum Number of History Messages Returned by Room"; value = tostring(get_historylength(event.room)); }); + table.insert(event.form, { + name = 'muc#roomconfig_defaulthistorymessages', + type = 'text-single', + label = 'Default Number of History Messages Returned by Room', + value = tostring(get_defaulthistorymessages(event.room)) + }); end, 100-10); module:hook("muc-config-submitted/muc#roomconfig_historylength", function(event) @@ -46,11 +65,17 @@ end end); +module:hook("muc-config-submitted/muc#roomconfig_defaulthistorymessages", function(event) + if set_defaulthistorymessages(event.room, event.value) then + event.status_codes["104"] = true; + end +end); + local function parse_history(stanza) local x_tag = stanza:get_child("x", "http://jabber.org/protocol/muc"); local history_tag = x_tag and x_tag:get_child("history", "http://jabber.org/protocol/muc"); if not history_tag then - return nil, default_history_length, nil; + return nil, nil, nil; end local maxchars = tonumber(history_tag.attr.maxchars); @@ -118,11 +143,16 @@ local function send_history(room, stanza) local maxchars, maxstanzas, since = parse_history(stanza); + if not(maxchars or maxstanzas or since) then + maxstanzas = get_defaulthistorymessages(room); + end local event = { room = room; stanza = stanza; to = stanza.attr.from; -- `to` is required to calculate the character count for `maxchars` - maxchars = maxchars, maxstanzas = maxstanzas, since = since; + maxchars = maxchars, + maxstanzas = maxstanzas, + since = since; next_stanza = function() end; -- events should define this iterator }; module:fire_event("muc-get-history", event);