Option to hide moderator name who made actions WIP (#137).
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
# mod_muc_anonymize_moderation_actions
|
||||
|
||||
This modules allows to anonymize affiliation and role changes in MUC rooms.
|
||||
|
||||
Enabling this module on a MUC Virtualhost will add a settings in the roomconfig form.
|
||||
When the feature is enabled, when a moderator changes the role or affiliation of an occupant (kick, ban, ...) their name will be removed from the broadcasted message, to not disclose who did the moderation action.
|
||||
|
||||
This is particularly usefull to prevent some revenge when a moderator bans someone.
|
||||
|
||||
This module is under AGPL-3.0 license.
|
||||
|
||||
It was tested on Prosody 0.12.x.
|
||||
|
||||
## Configuration
|
||||
|
||||
Just enable the module on your MUC VirtualHost.
|
||||
The feature will be accessible throught the room configuration form.
|
||||
|
||||
You can tweak the position of the settings in the MUC configuration form using `anonymize_moderation_actions_form_position`.
|
||||
This value will be passed as priority for the "muc-config-form" hook, so you can move field up by increasing the value, or down by decreasing the value.
|
||||
|
||||
By default, the field will be between muc#roomconfig_changesubject and muc#roomconfig_moderatedroom (default value is `78`).
|
||||
|
||||
``` lua
|
||||
VirtualHost "muc.example.com"
|
||||
modules_enabled = { "muc_anonymize_moderation_actions" }
|
||||
anonymize_moderation_actions_form_position = 96
|
||||
```
|
@ -0,0 +1,44 @@
|
||||
-- mod_muc_anonymize_moderation_actions
|
||||
--
|
||||
-- SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
||||
-- SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
-- form_position: the position in the room config form (this value will be passed as priority for the "muc-config-form" hook).
|
||||
-- By default, field will be between muc#roomconfig_changesubject and muc#roomconfig_moderatedroom
|
||||
local form_position = module:get_option_number("anonymize_moderation_actions_form_position") or 80-2;
|
||||
|
||||
local function get_anonymize_moderation_actions(room)
|
||||
return room._data.anonymize_moderation_actions or false;
|
||||
end
|
||||
|
||||
local function set_anonymize_moderation_actions(room, anonymize_moderation_actions)
|
||||
anonymize_moderation_actions = anonymize_moderation_actions and true or nil;
|
||||
if get_anonymize_moderation_actions(room) == anonymize_moderation_actions then return false; end
|
||||
room._data.anonymize_moderation_actions = anonymize_moderation_actions;
|
||||
return true;
|
||||
end
|
||||
|
||||
-- Config form declaration
|
||||
local function add_form_option(event)
|
||||
table.insert(event.form, {
|
||||
name = "muc#roomconfig_anonymize_moderation_actions";
|
||||
type = "boolean";
|
||||
label = "Anonymize moderation actions";
|
||||
desc = "When this is enabled, moderation actions will be anonymized, to avoid disclosing who is banning/kicking/… occupants.";
|
||||
value = get_anonymize_moderation_actions(event.room);
|
||||
});
|
||||
end
|
||||
|
||||
local function config_submitted(event)
|
||||
set_anonymize_moderation_actions(event.room, event.value);
|
||||
end
|
||||
|
||||
local function remove_actor(event)
|
||||
if (event.room and get_anonymize_moderation_actions(event.room)) then
|
||||
event.actor = nil;
|
||||
end
|
||||
end
|
||||
|
||||
module:hook("muc-config-submitted/muc#roomconfig_anonymize_moderation_actions", config_submitted);
|
||||
module:hook("muc-config-form", add_form_option, form_position);
|
||||
module:hook("muc-broadcast-presence", remove_actor);
|
@ -8,6 +8,7 @@
|
||||
-- * "slow_mode_duration"
|
||||
-- * "mute_anonymous"
|
||||
-- * "moderation_delay"
|
||||
-- * "anonymize_moderation_actions"
|
||||
-- These options are introduced in the Peertube livechat plugin.
|
||||
--
|
||||
-- The "slow_mode_duration" comes with mod_muc_slow_mode.
|
||||
@ -132,6 +133,9 @@ local function apply_config(room, settings)
|
||||
-- (and thus we don't need to broadcast changes)
|
||||
room._data.livechat_muc_terms = config.livechat_muc_terms;
|
||||
end
|
||||
if (type(config.anonymize_moderation_actions) == "boolean") then
|
||||
room._data.anonymize_moderation_actions = config.anonymize_moderation_actions;
|
||||
end
|
||||
elseif config ~= nil then
|
||||
module:log("error", "Invalid config returned from API for %s: %q", room.jid, config);
|
||||
return nil, "format", { field = "config" };
|
||||
|
Reference in New Issue
Block a user