From 495646d113af408f99120ef7d9e6b875583ee45d Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <ynerant@crans.org>
Date: Mon, 21 Jun 2021 20:32:12 +0200
Subject: [PATCH] [mailman3] Fix block to customize moderation messages

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
---
 roles/mailman3/tasks/main.yml | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/roles/mailman3/tasks/main.yml b/roles/mailman3/tasks/main.yml
index f697d3f5..c1471941 100644
--- a/roles/mailman3/tasks/main.yml
+++ b/roles/mailman3/tasks/main.yml
@@ -79,28 +79,24 @@
   notify: Restart mailman3-web
 
 # When notifying moderators daily, add link to moderation page
-- blockinfile:
+- name: Patch daily moderation mails
+  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.
+    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.\n\n{}\n\nVous pouvez gérer ces demandes via votre interface web :\nhttps://{{ mailman3.web_domains[0] }}/postorius/lists/{}/held_messages\n\"\"\").format(mlist.fqdn_listname, count, detail, mlist.fqdn_listname)"
 
-{}
-
-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:
+- name: Send owner notifications 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:
+- name: Patch moderation requests messages
+  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
-- 
GitLab