From 8d3ab61e7c136610ae1dc002226559e8c6b21fcb Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 3 Apr 2021 13:44:25 -0400 Subject: feat(panettone): Send email notifications for comments When a user posts a comment on an issue, send email notifications (respecting the enable-email-notifications setting) to the author of that issue and all the other users who have commented on that issue. Since the oauth & gmail API stuff that the relay does is slow, this happens in a background thread. Change-Id: Ic00c265deab1030d9ba64c29c9f56314dd179141 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2805 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: tazjin --- web/panettone/src/panettone.lisp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'web/panettone/src/panettone.lisp') diff --git a/web/panettone/src/panettone.lisp b/web/panettone/src/panettone.lisp index c97a988404fa..ba079df62b66 100644 --- a/web/panettone/src/panettone.lisp +++ b/web/panettone/src/panettone.lisp @@ -515,6 +515,23 @@ :issue-id id :body body :author-dn (dn *user*)) + + ;; Send email notifications (in a thread, since smtp is slow) + (let ((current-user *user*)) + (model:make-thread + (lambda () + (let ((issue (model:get-issue id))) + (dolist (user-dn (remove-duplicates + (cons (author-dn issue) + (model:issue-commenter-dns id)) + :test #'equal)) + (when (not (equal (dn current-user) user-dn)) + (email:notify-user + user-dn + :subject (format nil "~A commented on \"~A\"" + (displayname current-user) + (subject issue)) + :message body))))))) (redirect-to-issue))))) (defroute close-issue -- cgit 1.4.1