Slow mode WIP (#192):

* default delay is configurable in channel's chat rooms options.
This commit is contained in:
John Livingston
2024-02-13 12:49:22 +01:00
parent ee71d3f729
commit cf179d7f72
11 changed files with 91 additions and 3 deletions

View File

@ -1,8 +1,13 @@
-- Copyright (C) 2021 Kim Alvefur
-- Copyright (C) 2024 John Livingston
--
-- This file is MIT licensed. Please see the
-- COPYING file in the source package for more information.
--
-- This version contains a modification to take into account new config option "slow_mode_delay".
-- This option is introduced in the Peertube livechat plugin, by mod_muc_slow_mode.
-- There will be a XEP proposal. When done, these modifications will be submitted to the mod_muc_http_defaults maintainer.
--
local http = require "net.http";
local async = require "util.async";
@ -104,6 +109,11 @@ local function apply_config(room, settings)
-- mod_muc_mam
if type(config.archiving) == "boolean" then room._config.archiving = config.archiving; end
-- specific to peertube-plugin-livechat:
if (type(config.slow_mode_delay) == "number") and config.slow_mode_delay >= 0 then
room._data.slow_mode_delay = config.slow_mode_delay;
end
elseif config ~= nil then
module:log("error", "Invalid config returned from API for %s: %q", room.jid, config);
return nil, "format", { field = "config" };