[Patchew-devel] [PATCH] email: add to_user configuration

Paolo Bonzini posted 1 patch 4 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew next tags/patchew/20190417101545.9258-1-pbonzini@redhat.com
mods/email.py      | 5 +++++
mods/maintainer.py | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
[Patchew-devel] [PATCH] email: add to_user configuration
Posted by Paolo Bonzini 4 years, 11 months ago
This could be used to send email when a patch is added to the "watched" queue.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 mods/email.py      | 5 +++++
 mods/maintainer.py | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/mods/email.py b/mods/email.py
index 91c7d28..411bc4b 100644
--- a/mods/email.py
+++ b/mods/email.py
@@ -74,6 +74,9 @@ Email information is configured in "INI" style:
                         BooleanSchema("reply_subject", "Set replying subject",
                                       desc='Whether to set Subject to "Re: xxx", if the event has an associated email message',
                                       default=True),
+                        BooleanSchema("to_user", "Send to user",
+                                      desc='Whether to set To to a user email, if the event has an associated user',
+                                      default=False),
                         StringSchema("to", "To", desc="Send email to"),
                         StringSchema("cc", "Cc", desc="Cc list"),
                         StringSchema("subject_template", "Subject template",
@@ -246,6 +249,8 @@ Email information is configured in "INI" style:
                 headers["Reply-To"] = "<%s>" % mo.project.mailing_list
             if nt["reply_subject"] and mo:
                 subject = "Re: " + mo.subject if not mo.subject.startswith("Re:") else mo.subject
+            if nt["to_user"] and 'user' in params and params['user'].email:
+                to += params['user'].email
             if not (subject and body and (to or cc)):
                 continue
             headers["Subject"] = subject
diff --git a/mods/maintainer.py b/mods/maintainer.py
index 7093760..00b1586 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -38,13 +38,13 @@ class MaintainerModule(PatchewModule):
         for x in [m] + list(m.get_patches()):
             q, created = QueuedSeries.objects.get_or_create(user=user, message=x, name=queue)
             if created:
-                emit_event("MessageQueued", message=x, queue=q)
+                emit_event("MessageQueued", user=user, message=x, queue=q)
 
     def _drop_from_queue(self, user, m, queue):
         query = QueuedSeries.objects.filter(user=user, message__in=m.get_patches() + [m],
                                      name=queue)
         for q in query:
-            emit_event("MessageDropping", message=q.message, queue=q)
+            emit_event("MessageDropping", user=user, message=q.message, queue=q)
         q.delete()
 
     def _update_watch_queue(self, series):
-- 
2.21.0

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel