diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-04-03T17·44-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2021-04-04T14·17+0000 |
commit | 8d3ab61e7c136610ae1dc002226559e8c6b21fcb (patch) | |
tree | 31e41b2ad44b2e8abe26e4677c61a4046bdd008a /web/panettone/src/panettone.lisp | |
parent | 349b98ccc841587aadc6a2de5684f093cd72d628 (diff) |
feat(panettone): Send email notifications for comments r/2427
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 <sternenseemann@systemli.org> Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'web/panettone/src/panettone.lisp')
-rw-r--r-- | web/panettone/src/panettone.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
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 |