diff --git a/seyren-core/src/main/java/com/seyren/core/service/notification/SlackNotificationService.java b/seyren-core/src/main/java/com/seyren/core/service/notification/SlackNotificationService.java index 022e26fc..0e093550 100644 --- a/seyren-core/src/main/java/com/seyren/core/service/notification/SlackNotificationService.java +++ b/seyren-core/src/main/java/com/seyren/core/service/notification/SlackNotificationService.java @@ -119,16 +119,24 @@ public String apply(Alert input) { return String.format("%s = %s", input.getTarget(), input.getValue().toString()); } })); - + String channel = subscription.getTarget().contains("!") ? "" : ""; + String description; + if (StringUtils.isNotBlank(check.getDescription())) { + description = String.format("\n> %s", check.getDescription()); + } else { + description = ""; + } + final String state = check.getState().toString(); - return String.format("%s%s %s [%s]\n```\n%s\n```\n#%s %s", + return String.format("%s*%s* %s [%s]%s\n```\n%s\n```\n#%s %s", Iterables.get(emojis, check.getState().ordinal(), ""), state, check.getName(), url, + description, alertsString, state.toLowerCase(Locale.getDefault()), channel diff --git a/seyren-core/src/test/java/com/seyren/core/service/notification/SlackNotificationServiceTest.java b/seyren-core/src/test/java/com/seyren/core/service/notification/SlackNotificationServiceTest.java index cd6aee8a..00190953 100644 --- a/seyren-core/src/test/java/com/seyren/core/service/notification/SlackNotificationServiceTest.java +++ b/seyren-core/src/test/java/com/seyren/core/service/notification/SlackNotificationServiceTest.java @@ -113,7 +113,7 @@ public void basicSlackTest() { assertThat(content, Matchers.containsString("token=")); assertThat(content, Matchers.containsString("&channel=target")); assertThat(content, not(Matchers.containsString(encode("")))); - assertThat(content, Matchers.containsString(encode("ERROR test-check"))); + assertThat(content, Matchers.containsString(encode("*ERROR* test-check"))); assertThat(content, Matchers.containsString(encode("/#/checks/123"))); assertThat(content, Matchers.containsString("&username=Seyren")); assertThat(content, Matchers.containsString("&icon_url=")); @@ -162,7 +162,7 @@ public void mentionChannelWhenTargetContainsExclamationTest() { assertThat(content, Matchers.containsString("token=")); assertThat(content, Matchers.containsString("&channel=target")); assertThat(content, Matchers.containsString(encode(""))); - assertThat(content, Matchers.containsString(encode("ERROR test-check"))); + assertThat(content, Matchers.containsString(encode("*ERROR* test-check"))); assertThat(content, Matchers.containsString(encode("/#/checks/123"))); assertThat(content, Matchers.containsString("&username=Seyren")); assertThat(content, Matchers.containsString("&icon_url="));