diff options
author | Bjørn Christian Seime <bjorn.christian@seime.no> | 2023-10-25 13:10:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 13:10:05 +0200 |
commit | 8b1ba4516d0a7cc0c686c5a361b980203f8c9ac6 (patch) | |
tree | d4b425557e2c15898f88b5b8723a05b7cf8ee35e | |
parent | 0634690d264465eea71a053bd90617ab16b23ca0 (diff) | |
parent | 02442fdfc09f468dd4eef835cd7c3cc64aea2be6 (diff) |
Merge pull request #29093 from vespa-engine/bjorncs/trial-notifications
Skip notification emails if no-one subscribing
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java index b0b43866fae..f27e69c4636 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java @@ -101,10 +101,13 @@ public class Notifier { log.fine(() -> "Sending notification " + notification + " to " + contacts.stream().map(c -> c.email().getEmailAddress()).toList()); var content = formatter.format(notification); - mailer.send(mailOf(content, contacts.stream() - .filter(c -> c.email().isVerified()) - .map(c -> c.email().getEmailAddress()) - .toList())); + var verifiedContacts = contacts.stream() + .filter(c -> c.email().isVerified()).map(c -> c.email().getEmailAddress()).toList(); + if (verifiedContacts.isEmpty()) { + log.fine(() -> "None of the %d contact(s) are verified - skipping delivery of %s".formatted(contacts.size(), notification)); + return; + } + mailer.send(mailOf(content, verifiedContacts)); } catch (MailerException e) { log.log(Level.SEVERE, "Failed sending email", e); } catch (MissingOptionalException e) { |