diff options
author | Leandro Alves <leandroalves@yahooinc.com> | 2022-06-30 14:06:38 +0200 |
---|---|---|
committer | Leandro Alves <leandroalves@yahooinc.com> | 2022-06-30 14:06:38 +0200 |
commit | 96dcfb0e8fe953357198001202687f433f2506c8 (patch) | |
tree | 2e057811dc29d33ceaf8cd484a90a684f42ab7f3 /controller-server | |
parent | 3e66f4bb7f70c3135b720b7d5e39db8c0b24fd8b (diff) |
Add basic header to notification email
Diffstat (limited to 'controller-server')
2 files changed, 33 insertions, 14 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 49c819548fe..f2c9d55b2a2 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 @@ -29,6 +29,16 @@ import java.util.stream.Collectors; * @author enygaard */ public class Notifier { + private static final String header = """ + <div style="background: #00598c; height: 55px; width: 100%"> + <img + src="https://vespa.ai/assets/vespa-logo.png" + style="width: auto; height: 34px; margin: 10px" + /> + </div> + <br> + """; + private final CuratorDb curatorDb; private final Mailer mailer; private final FlagSource flagSource; @@ -111,14 +121,15 @@ public class Notifier { public Mail mailOf(FormattedNotification content, Collection<String> recipients) { var notification = content.notification(); var subject = Text.format("[%s] %s Vespa Notification for %s", notification.level().toString().toUpperCase(), content.prettyType(), applicationIdSource(notification.source())); - var body = new StringBuilder(); - body.append(content.messagePrefix()).append("\n") + String body = new StringBuilder() + .append(content.messagePrefix()).append("\n") .append(notification.messages().stream().map(m -> " * " + m).collect(Collectors.joining("\n"))).append("\n") .append("\n") .append("Vespa Console link:\n") - .append(content.uri().toString()); - var html = new StringBuilder(); - html.append(content.messagePrefix()).append("<br>\n") + .append(content.uri().toString()).toString(); + String html = new StringBuilder() + .append(header) + .append(content.messagePrefix()).append("<br>\n") .append("<ul>\n") .append(notification.messages().stream() .map(Notifier::linkify) @@ -126,8 +137,8 @@ public class Notifier { .collect(Collectors.joining("<br>\n"))) .append("</ul>\n") .append("<br>\n") - .append("<a href=\"" + content.uri() + "\">Vespa Console</a>"); - return new Mail(recipients, subject, body.toString(), html.toString()); + .append("<a href=\"" + content.uri() + "\">Vespa Console</a>").toString(); + return new Mail(recipients, subject, body, html); } @VisibleForTesting diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java index 8bf0e584892..4132db74140 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java @@ -68,12 +68,20 @@ public class NotifierTest { var mail = mailer.inbox(email).get(0); assertEquals("[WARNING] Test package Vespa Notification for tenant1.default.default", mail.subject()); - assertEquals("There are problems with tests for default.default<br>\n" + - "<ul>\n" + - "<li>test package has production tests, but no production tests are declared in deployment.xml</li><br>\n" + - "<li>see <a href=\"https://docs.vespa.ai/en/testing.html\">https://docs.vespa.ai/en/testing.html</a> for details on how to write system tests for Vespa</li></ul>\n" + - "<br>\n" + - "<a href=\"https://dashboard.tld/tenant1/default\">Vespa Console</a>", + assertEquals(""" + <div style="background: #00598c; height: 55px; width: 100%"> + <img + src="https://vespa.ai/assets/vespa-logo.png" + style="width: auto; height: 34px; margin: 10px" + /> + </div> + <br> + There are problems with tests for default.default<br> + <ul> + <li>test package has production tests, but no production tests are declared in deployment.xml</li><br> + <li>see <a href="https://docs.vespa.ai/en/testing.html">https://docs.vespa.ai/en/testing.html</a> for details on how to write system tests for Vespa</li></ul> + <br> + <a href="https://dashboard.tld/tenant1/default">Vespa Console</a>""", mail.htmlMessage().get()); } @@ -84,4 +92,4 @@ public class NotifierTest { "No url.", "No url."); data.forEach((input, expected) -> assertEquals(expected, Notifier.linkify(input))); } -}
\ No newline at end of file +} |