From 1f7a86d4a763f1f63fa346c66cf5247e9fda97fe Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <ynerant@crans.org>
Date: Mon, 3 May 2021 08:54:59 +0200
Subject: [PATCH] [mailman3] Patch sources to add moderation links in emails

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
---
 roles/mailman3/tasks/main.yml                 | 29 +++++++++++++++++++
 .../fr/list:admin:action:post.txt.j2          | 15 ++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 roles/mailman3/templates/mailman/templates/fr/list:admin:action:post.txt.j2

diff --git a/roles/mailman3/tasks/main.yml b/roles/mailman3/tasks/main.yml
index b6f84d9a..f697d3f5 100644
--- a/roles/mailman3/tasks/main.yml
+++ b/roles/mailman3/tasks/main.yml
@@ -78,6 +78,35 @@
   become_user: www-data
   notify: Restart mailman3-web
 
+# When notifying moderators daily, add link to moderation page
+- blockinfile:
+    path: /usr/lib/python3/dist-packages/mailman/commands/cli_notify.py
+    marker: "{mark}"
+    marker_begin: '# XXX This should be a template.'
+    marker_end: 'msg = OwnerNotification(mlist, subject, text, mlist.administrators)'
+    block: |-
+      text = _("""La liste {} a {} requêtes de modération en attente.
+
+{}
+
+Vous pouvez gérer ces demandes via votre interface web :
+https://{{ mailman3.web_domains[0] }}/postorius/lists/{}/held_messages
+
+# Owner notifications are sent from listname-bounces@domain.
+- lineinfile:
+    path: /usr/lib/python3/dist-packages/mailman/email/message.py
+    regexp: '        sender ='
+    line: '        sender = f"{mlist.list_name}-bounces@{mlist.domain.mail_host}"'
+
+
+# When notifying moderators of a new incoming message, add link to moderation page
+- template:
+    src: mailman/templates/fr/list:admin:action:post.txt.j2
+    dest: /usr/lib/python3/dist-packages/mailman/templates/fr/list:admin:action:post.txt
+    owner: root
+    group: root
+    mode: 0644
+
 - name: Indicate role in motd
   template:
     src: update-motd.d/05-service.j2
diff --git a/roles/mailman3/templates/mailman/templates/fr/list:admin:action:post.txt.j2 b/roles/mailman3/templates/mailman/templates/fr/list:admin:action:post.txt.j2
new file mode 100644
index 00000000..f9d7cb39
--- /dev/null
+++ b/roles/mailman3/templates/mailman/templates/fr/list:admin:action:post.txt.j2
@@ -0,0 +1,15 @@
+En tant qu’administrateur d’une liste, votre autorisation est nécessaire pour
+valider le message suivant :
+
+    Liste : $listname
+    De :    $sender_email
+    Objet : $subject
+
+Ce message a besoin d’une validation car :
+
+$reasons
+
+Vous pouvez vous rendre sur votre tableau de bord pour donner suite, ou non, à
+cette requête :
+
+https://{{ mailman3.web_domains[0] }}/postorius/lists/$listname/held_messages
-- 
GitLab