fix(web/panettone): Only send emails if the email is known

Upcoming changes to the authentication model may mean that user
objects do not have an email address attached.

Change-Id: I4fddb810f723c790d243f779714ca7f189a02aeb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5770
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-05-28 18:06:37 +02:00 committed by tazjin
parent 38be32c6b0
commit 10768741cd
2 changed files with 4 additions and 3 deletions

View file

@ -41,8 +41,9 @@ values of `*smtp-server*', `*smtp-server-port*' and `*email-notification-from*'"
"Sends an email notification to the user with DN with the given SUBJECT and
MESSAGE, iff that user has not disabled email notifications"
(when (user-has-email-notifications-enabled-p dn)
(when-let ((user (find-user-by-dn dn)))
(when-let* ((user (find-user-by-dn dn))
(user-mail user))
(send-email-notification
:to (mail user)
:to user-mail
:subject subject
:message message))))

View file

@ -55,7 +55,7 @@
(defpackage panettone.email
(:nicknames :email)
(:use :cl)
(:import-from :alexandria :when-let)
(:import-from :alexandria :when-let :when-let*)
(:import-from :panettone.model
:settings-for-user :enable-email-notifications-p)
(:import-from :panettone.authentication