[aur-dev][PATCH] notify: add X-AUR-Reason header to allow conveniently filtering emails

Eli Schwartz eschwartz at archlinux.org
Fri Oct 5 20:29:22 UTC 2018


Because filtering by matching the sender && regular expressions on the
subject is awkward.

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---

In order to remain generic enough to allow the notify script to be
imported from and used elsewhere, we cannot just use sys.argv[1] as the
reason.

 aurweb/scripts/notify.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py
index 44eec84..d975086 100755
--- a/aurweb/scripts/notify.py
+++ b/aurweb/scripts/notify.py
@@ -63,6 +63,9 @@ class Notification:
         sendmail = aurweb.config.get('notifications', 'sendmail')
         sender = aurweb.config.get('notifications', 'sender')
         reply_to = aurweb.config.get('notifications', 'reply-to')
+        reason = self.__class__.__name__
+        if reason.endswith('Notification'):
+            reason = reason[:-len('Notification')]
 
         for recipient in self.get_recipients():
             to, lang = recipient
@@ -72,6 +75,7 @@ class Notification:
             msg['From'] = sender
             msg['Reply-to'] = reply_to
             msg['To'] = to
+            msg['X-AUR-Reason'] = reason
 
             for key, value in self.get_headers().items():
                 msg[key] = value
-- 
2.19.0


More information about the aur-dev mailing list