Slow Mode WIP (#192): option position

This commit is contained in:
John Livingston 2024-02-14 09:26:01 +01:00
parent 9ed689b5f1
commit afbc78d0e6
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 26 additions and 1 deletions

View File

@ -5,3 +5,19 @@ 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.
## Configuration
Just enable the module on your MUC component.
The feature will be accessible throught the room configuration form.
Depending on your application, it is possible that the slow mode is more important than other fields (for example for a video streaming service).
The position in the room config form can be changed be setting the option `slow_mode_delay_form_position`.
This value will be passed as priority for the "muc-config-form" hook.
By default, the field will be between muc#roomconfig_changesubject and muc#roomconfig_moderatedroom.
``` lua
VirtualHost "muc.example.com"
modules_enabled = { "muc_slow_mode" }
slow_mode_delay_form_position = 96
```

View File

@ -22,6 +22,14 @@ local valid_roles = muc_util.valid_roles;
-- Namespaces
local xmlns_muc = "http://jabber.org/protocol/muc";
-- Options
-- form_position: the position in the room config form (this value will be passed as priority for the "muc-config-form" hook).
-- Depending on your application, it is possible that the slow mode is more important than other fields (for example for a video streaming service).
-- So there is an option to change this.
-- By default, field will be between muc#roomconfig_changesubject and muc#roomconfig_moderatedroom
local form_position = module:get_option_number("slow_mode_delay_form_position") or 80-2;
-- Getter/Setter
local function get_slow_mode_delay(room)
return room._data.slow_mode_delay or 0;
@ -68,7 +76,7 @@ module:hook("muc-config-submitted/muc#roomconfig_slow_mode_delay", function(even
end
end);
module:hook("muc-config-form", add_form_option, 100-4);
module:hook("muc-config-form", add_form_option, form_position);
-- handling groupchat messages
function handle_groupchat(event)

View File

@ -207,6 +207,7 @@ class ProsodyConfigContent {
this.muc.set('muc_room_default_history_length', 20)
this.muc.add('modules_enabled', 'muc_slow_mode')
this.muc.add('slow_mode_delay_form_position', 120)
}
useAnonymous (autoBanIP: boolean): void {