diff --git a/prosody-modules/mod_muc_slow_mode/README.md b/prosody-modules/mod_muc_slow_mode/README.md index 7705824b..71f213e0 100644 --- a/prosody-modules/mod_muc_slow_mode/README.md +++ b/prosody-modules/mod_muc_slow_mode/README.md @@ -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 +``` diff --git a/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua b/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua index 1a0001b4..ecfc5fd4 100644 --- a/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua +++ b/prosody-modules/mod_muc_slow_mode/mod_muc_slow_mode.lua @@ -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) diff --git a/server/lib/prosody/config/content.ts b/server/lib/prosody/config/content.ts index 60a134ba..0f2c2ebd 100644 --- a/server/lib/prosody/config/content.ts +++ b/server/lib/prosody/config/content.ts @@ -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 {