[Patchew-devel] [PATCH v2 09/12] maintainer: Add MessageQueued and MessageDropping events

Paolo Bonzini pbonzini at redhat.com
Wed Nov 28 20:49:59 UTC 2018


Two small changes I'd like here:

On 28/11/18 15:35, Fam Zheng wrote:
>      def _add_to_queue(self, user, m, queue):
>          for x in [m] + list(m.get_patches()):
> -            Queue.objects.get_or_create(user=user, message=x, name=queue)
> +            q, created = Queue.objects.get_or_create(user=user, message=x, name=queue)
> +            if created:
> +                emit_event("MessageQueued", message=x, queue=q)

I'd "explode" queue into name and user here.  The idea is that we could
have something generic like this in mods/email.py:

diff --git a/mods/email.py b/mods/email.py
index 91c7d28..3ab1a73 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 email message',
+                                      default=True),
                         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:
+                to += params['user'].email
             if not (subject and body and (to or cc)):
                 continue
             headers["Subject"] = subject

... that would result in sending the message to the user that configured
a WatchQuery.

>  
>      def _drop_from_queue(self, user, m, queue):
>          query = Queue.objects.filter(user=user, message__in=m.get_patches() + [m],
>                                       name=queue)
> +        for q in query:
> +            emit_event("MessageDropping", message=q.message, queue=q)

Dropped?

>          q.delete()
>  
>      def _update_watch_queue(self, series):
> 




More information about the Patchew-devel mailing list