Slow mode WIP (#192):
* new option in room configuration to set the slow mode delay (new prosody module mod_muc_slow_mode).
This commit is contained in:
parent
f8647872d5
commit
ee71d3f729
@ -2,6 +2,11 @@
|
||||
|
||||
## 8.3.0 (Not Released Yet)
|
||||
|
||||
### New features
|
||||
|
||||
* Slow mode (#192):
|
||||
* new option in room configuration to set the slow mode delay (new prosody module mod_muc_slow_mode).
|
||||
|
||||
### Minor changes and fixes
|
||||
|
||||
* Fix ConverseJS build: translations were missing, and only english was available.
|
||||
|
7
prosody-modules/mod_muc_slow_mode/README.md
Normal file
7
prosody-modules/mod_muc_slow_mode/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# mod_muc_slow_mode
|
||||
|
||||
This module is a custom module that allows slow mode for MUC rooms.
|
||||
|
||||
This module is part of peertube-plugin-livechat, and is under the same LICENSE.
|
||||
|
||||
There will probably be a XEP proposal for this module behaviour. When done, this module will be published in the prosody-modules repository.
|
62
prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua
Normal file
62
prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua
Normal file
@ -0,0 +1,62 @@
|
||||
-- mod_muc_slow_mode
|
||||
--
|
||||
-- Copyright (C) 2024 John Livingston
|
||||
--
|
||||
-- This file is AGPL-v3 licensed.
|
||||
-- Please see the Peertube livechat plugin copyright information.
|
||||
-- https://livingston.frama.io/peertube-plugin-livechat/credits/
|
||||
--
|
||||
-- Implements: XEP-????: MUC Slow Mode (XEP to come).
|
||||
--
|
||||
-- Imports
|
||||
|
||||
-- Plugin dependencies
|
||||
local mod_muc = module:depends "muc";
|
||||
|
||||
-- Getter/Setter
|
||||
local function get_slow_mode_delay(room)
|
||||
return room._data.slow_mode_delay or 0;
|
||||
end
|
||||
|
||||
local function set_slow_mode_delay(room, delay)
|
||||
if delay then
|
||||
delay = assert(tonumber(delay), "Slow mode delay is not a valid number");
|
||||
end
|
||||
if delay and delay < 0 then
|
||||
delay = 0;
|
||||
end
|
||||
room._data.slow_mode_delay = delay;
|
||||
return true;
|
||||
end
|
||||
|
||||
-- Discovering support
|
||||
local function add_disco_form(event)
|
||||
table.insert(event.room, {
|
||||
name = "muc#roomconfig_slow_mode_delay";
|
||||
value = "";
|
||||
});
|
||||
event.formdata["muc#roomconfig_slow_mode_delay"] = get_slow_mode_delay(event.room);
|
||||
end
|
||||
|
||||
module:hook("mub-disco#info", add_disco_form);
|
||||
|
||||
-- Config form declaration
|
||||
local function add_form_option(event)
|
||||
table.insert(event.form, {
|
||||
name = "muc#roomconfig_slow_mode_delay";
|
||||
type = "text-single";
|
||||
datatype = "xs:integer";
|
||||
label = "Slow Mode (0=disabled, any positive integer= minimal delay in seconds between two messages from the same user)";
|
||||
desc = "Minimal delay, in seconds, between two messages for the same user in the room. If value is set to 0, the slow mode is not active.";
|
||||
value = get_slow_mode_delay(event.room);
|
||||
});
|
||||
end
|
||||
|
||||
module:hook("muc-config-submitted/muc#roomconfig_slow_mode_delay", function(event)
|
||||
if set_slow_mode_delay(event.room, event.value) then
|
||||
-- status 104 = configuration change: Inform occupants that a non-privacy-related room configuration change has occurred
|
||||
event.status_codes["104"] = true;
|
||||
end
|
||||
end);
|
||||
|
||||
module:hook("muc-config-form", add_form_option, 100-4);
|
@ -205,6 +205,8 @@ class ProsodyConfigContent {
|
||||
this.muc.set('muc_room_default_public_jids', false)
|
||||
this.muc.set('muc_room_default_change_subject', false)
|
||||
this.muc.set('muc_room_default_history_length', 20)
|
||||
|
||||
this.muc.add('modules_enabled', 'muc_slow_mode')
|
||||
}
|
||||
|
||||
useAnonymous (autoBanIP: boolean): void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user