annotate mod_alias/mod_alias.lua @ 6214:cc5c0f1dc89b

mod_muc_anonymize_moderation_actions: Fix mentioning Virtualhost for MUC, Compatibility section and License. diff --git a/mod_muc_anonymize_moderation_actions/README.md b/mod_muc_anonymize_moderation_actions/README.md --- a/mod_muc_anonymize_moderation_actions/README.md +++ b/mod_muc_anonymize_moderation_actions/README.md @@ -1,8 +1,10 @@ -<!-- -SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/> -SPDX-License-Identifier: AGPL-3.0-only ---> -# mod_muc_anonymize_moderation_actions +--- +labels: +- 'Stage-Alpha' +summary: Anonymize moderator actions for participants +--- + +## Introduction This modules allows to anonymize affiliation and role changes in MUC rooms. @@ -11,13 +13,10 @@ When the feature is enabled, when a mode 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. +Just enable the module on your MUC Component. 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`. @@ -26,7 +25,20 @@ This value will be passed as priority fo By default, the field will be between muc#roomconfig_changesubject and muc#roomconfig_moderatedroom (default value is `78`). ``` lua -VirtualHost "muc.example.com" +Component "muc.example.com" "muc" modules_enabled = { "muc_anonymize_moderation_actions" } anonymize_moderation_actions_form_position = 96 ``` + +## Compatibility + + ------ ---------------------- + trunk Works as of 25-05-12 + 0.13 Works + 0.12 Works + ------ ---------------------- + +### License + +SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/> +SPDX-License-Identifier: AGPL-3.0-only
author Menel <menel@snikket.de>
date Mon, 12 May 2025 10:42:26 +0200
parents 65082d91950e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1953
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
1 -- Copyright (C) 2015 Travis Burtrum
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
2 -- This file is MIT/X11 licensed.
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
3
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
4 -- set like so in prosody config, works on full or bare jids, or hosts:
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
5 --aliases = {
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
6 -- ["old@example.net"] = "new@example.net";
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
7 -- ["you@example.com"] = "you@example.net";
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
8 -- ["conference.example.com"] = "conference.example.net";
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
9 --}
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
10
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
11 local aliases = module:get_option("aliases", {});
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
12 local alias_response = module:get_option("alias_response", "User $alias can be contacted at $target");
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
13
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
14 local st = require "util.stanza";
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
15
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
16 function handle_alias(event)
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
17
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
18 if event.stanza.attr.type ~= "error" then
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
19 local alias = event.stanza.attr.to;
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
20 local target = aliases[alias];
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
21 if target then
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
22 local replacements = {
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
23 alias = alias,
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
24 target = target
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
25 };
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
26 local error_message = alias_response:gsub("%$([%w_]+)", function (v)
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
27 return replacements[v] or nil;
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
28 end);
2887
65082d91950e Many modules: Simplify st.message(…):tag("body"):text(…):up() into st.message(…, …)
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 1953
diff changeset
29 local message = st.message({ type = "chat", from = alias, to = event.stanza.attr.from }, error_message);
1953
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
30 module:send(message);
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
31 return event.origin.send(st.error_reply(event.stanza, "cancel", "gone", error_message));
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
32 end
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
33 end
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
34
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
35 end
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
36
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
37 module:hook("message/bare", handle_alias, 300);
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
38 module:hook("message/full", handle_alias, 300);
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
39 module:hook("message/host", handle_alias, 300);
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
40
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
41 module:hook("presence/bare", handle_alias, 300);
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
42 module:hook("presence/full", handle_alias, 300);
0c3ba5ff7a3b mod_alias: New alias module
moparisthebest <admin@moparisthebest.com>
parents:
diff changeset
43 module:hook("presence/host", handle_alias, 300);