notify: add X-AUR-Reason header to allow conveniently filtering emails
diff mbox

Message ID 20181005202922.26525-1-eschwartz@archlinux.org
State New
Headers show

Commit Message

Eli Schwartz Oct. 5, 2018, 8:29 p.m. UTC
Because filtering by matching the sender && regular expressions on the
subject is awkward.

Signed-off-by: Eli Schwartz <eschwartz@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(+)

Patch
diff mbox

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