Option to hide moderator name who made actions WIP (#137).

This commit is contained in:
John Livingston 2024-07-26 17:04:14 +02:00
parent 38f2b2af57
commit ebc8fc8797
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
13 changed files with 140 additions and 4 deletions

View File

@ -6,6 +6,7 @@
* Updating ConverseJS, to use upstream (v11 WIP). This comes with many improvments and new features.
* #146: copy message button for moderators.
* #137: option to hide moderator name who made actions (kick, ban, message moderation, ...).
### Minor changes and fixes

View File

@ -133,3 +133,5 @@ declare const LOC_POLL_VOTE_OK: string
declare const LOC_MODERATION_DELAY: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_MODERATION_DELAY_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_ANONYMIZE_MODERATION_LABEL: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_ANONYMIZE_MODERATION_DESC: string

View File

@ -167,7 +167,7 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
<label>
<input
type="checkbox"
name="bot"
name="mute_anonymous"
id="peertube-livechat-mute-anonymous"
@input=${(event: InputEvent) => {
if (event?.target && el.channelConfiguration) {
@ -254,6 +254,32 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
${el.renderFeedback('peertube-livechat-moderation-delay-feedback', 'moderation.delay')}
</div>
<livechat-configuration-section-header
.label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_ANONYMIZE_MODERATION_LABEL)}
.description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_ANONYMIZE_MODERATION_DESC, true)}
.helpPage=${'documentation/user/streamers/moderation'}>
</livechat-configuration-section-header>
<div class="form-group">
<label>
<input
type="checkbox"
name="anonymize-moderation"
id="peertube-livechat-anonymize-moderation"
@input=${(event: InputEvent) => {
if (event?.target && el.channelConfiguration) {
el.channelConfiguration.configuration.moderation.anonymize =
(event.target as HTMLInputElement).checked
}
el.requestUpdate('channelConfiguration')
}
}
value="1"
?checked=${el.channelConfiguration?.configuration.moderation.anonymize}
/>
${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_ANONYMIZE_MODERATION_LABEL)}
</label>
</div>
<livechat-configuration-section-header
.label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE)}
.description=${''}

View File

@ -588,3 +588,8 @@ livechat_configuration_channel_moderation_delay_desc: |
<li>0: moderation delay disabled</li>
<li>Any positive integer: messages will be delayed for X seconds for non-moderator participants, allowing moderators to delete message before any user can read it.</li>
</ul>
livechat_configuration_channel_anonymize_moderation_label: "Anonymize moderation actions"
livechat_configuration_channel_anonymize_moderation_desc: |
Anonymize moderation actions default value for new rooms.
When this is enabled, moderation actions will be anonymized, to avoid disclosing who is banning/kicking/… occupants.

View File

@ -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
```

View File

@ -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);

View File

@ -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" };

View File

@ -38,6 +38,7 @@ async function sanitizeChannelConfigurationOptions (
const moderationData = data.moderation ?? {} // comes with livechat 10.3.0
moderationData.delay ??= 0
moderationData.anonymize ??= false // comes with livechat 11.0.0
// mute not present in livechat <= 10.2.0
const mute = data.mute ?? {}
@ -73,7 +74,8 @@ async function sanitizeChannelConfigurationOptions (
anonymous: _readBoolean(mute, 'anonymous')
},
moderation: {
delay: _readInteger(moderationData, 'delay', 0, 60)
delay: _readInteger(moderationData, 'delay', 0, 60),
anonymize: _readBoolean(moderationData, 'anonymize')
}
}
if (terms !== undefined) {

View File

@ -54,7 +54,8 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
anonymous: false
},
moderation: {
delay: 0
delay: 0,
anonymize: false
},
terms: undefined
}

View File

@ -255,6 +255,9 @@ class ProsodyConfigContent {
this.muc.add('modules_enabled', 'muc_moderation_delay')
this.muc.set('moderation_delay_form_position', 118)
this.muc.add('modules_enabled', 'muc_anonymize_moderation_actions')
this.muc.set('anonymize_moderation_actions_form_position', 117)
}
useAnonymous (autoBanIP: boolean): void {

View File

@ -39,6 +39,7 @@ interface RoomDefaults {
mute_anonymous?: boolean
livechat_muc_terms?: string
moderation_delay?: number
anonymize_moderation_actions?: boolean
}
affiliations?: Affiliations
}
@ -54,7 +55,8 @@ async function _getChannelSpecificOptions (
slow_mode_duration: channelOptions.slowMode.duration,
mute_anonymous: channelOptions.mute.anonymous,
livechat_muc_terms: channelOptions.terms,
moderation_delay: channelOptions.moderation.delay
moderation_delay: channelOptions.moderation.delay,
anonymize_moderation_actions: channelOptions.moderation.anonymize
}
}

View File

@ -109,6 +109,7 @@ interface ChannelConfigurationOptions {
terms?: string // comes with Livechat 10.2.0
moderation: { // comes with Livechat 10.3.0
delay: number
anonymize: boolean // comes with Livechat 11.0.0
}
}

View File

@ -73,6 +73,19 @@ This section is still incomplete.
You can promote users as moderators, if you need some help.
## {{% livechat_label livechat_configuration_channel_anonymize_moderation_label %}}
{{% notice info %}}
This feature comes with the livechat plugin version 11.0.0.
{{% /notice %}}
It is possible to anonymize moderation actions, to avoid disclosing who is banning/kicking/… occupants."
To enable or disable this feature, use the [chat dropdown menu](/peertube-plugin-livechat/documentation/user/viewers), open the "configure" menu.
In the form, you will find a "{{% livechat_label livechat_configuration_channel_anonymize_moderation_label %}}" checkbox.
You can choose to enable or disable this feature for new chatrooms on the [channel configuration page](/peertube-plugin-livechat/documentation/user/streamers/channel).
## Delete room content
You can delete old rooms: join the room, and use the menu on the top to destroy the room.