diff --git a/server/src/main/java/com/objectcomputing/checkins/configuration/CheckInsConfiguration.java b/server/src/main/java/com/objectcomputing/checkins/configuration/CheckInsConfiguration.java index f8e8d7f92..d29dedbe8 100644 --- a/server/src/main/java/com/objectcomputing/checkins/configuration/CheckInsConfiguration.java +++ b/server/src/main/java/com/objectcomputing/checkins/configuration/CheckInsConfiguration.java @@ -32,10 +32,7 @@ public static class ApplicationConfig { private GoogleApiConfig googleApi; @NotNull - private NotificationsConfig notifications; - - @NotNull - private PulseResponseConfig pulseResponse; + private SlackConfig slack; @Getter @Setter @@ -75,42 +72,16 @@ public static class ScopeConfig { @Getter @Setter - @ConfigurationProperties("notifications") - public static class NotificationsConfig { - - @NotNull - private SlackConfig slack; - - @Getter - @Setter - @ConfigurationProperties("slack") - public static class SlackConfig { - @NotBlank - private String webhookUrl; - - @NotBlank - private String botToken; - } - } - - @Getter - @Setter - @ConfigurationProperties("pulse-response") - public static class PulseResponseConfig { - - @NotNull - private SlackConfig slack; + @ConfigurationProperties("slack") + public static class SlackConfig { + @NotBlank + private String webhookUrl; - @Getter - @Setter - @ConfigurationProperties("slack") - public static class SlackConfig { - @NotBlank - private String signingSecret; + @NotBlank + private String botToken; - @NotBlank - private String botToken; - } + @NotBlank + private String signingSecret; } } } diff --git a/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackPoster.java b/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackPoster.java index be08f13e1..b1839f649 100644 --- a/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackPoster.java +++ b/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackPoster.java @@ -21,8 +21,9 @@ public class SlackPoster { private CheckInsConfiguration configuration; public HttpResponse post(String slackBlock) { - // See if we can have a webhook URL. - String slackWebHook = configuration.getApplication().getNotifications().getSlack().getWebhookUrl(); + // See if we have a webhook URL. + String slackWebHook = configuration.getApplication() + .getSlack().getWebhookUrl(); if (slackWebHook != null) { // POST it to Slack. BlockingHttpClient client = slackClient.toBlocking(); diff --git a/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackSearch.java b/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackSearch.java index a8952e7b1..e7fbb6fed 100644 --- a/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackSearch.java +++ b/server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackSearch.java @@ -34,7 +34,7 @@ public SlackSearch(CheckInsConfiguration checkInsConfiguration) { } public String findChannelId(String channelName) { - String token = configuration.getApplication().getNotifications().getSlack().getBotToken(); + String token = configuration.getApplication().getSlack().getBotToken(); if (token != null) { try { MethodsClient client = Slack.getInstance().methods(token); @@ -59,7 +59,7 @@ public String findChannelId(String channelName) { } public String findUserId(String userEmail) { - String token = configuration.getApplication().getNotifications().getSlack().getBotToken(); + String token = configuration.getApplication().getSlack().getBotToken(); if (token != null) { try { MethodsClient client = Slack.getInstance().methods(token); @@ -80,7 +80,7 @@ public String findUserId(String userEmail) { } public String findUserEmail(String userId) { - String token = configuration.getApplication().getNotifications().getSlack().getBotToken(); + String token = configuration.getApplication().getSlack().getBotToken(); if (token != null) { try { MethodsClient client = Slack.getInstance().methods(token); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseSlackCommand.java b/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseSlackCommand.java index 439de89da..1c48eb30b 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseSlackCommand.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseSlackCommand.java @@ -35,7 +35,6 @@ public boolean send(String triggerId) { // See if we have a token. String token = configuration.getApplication() - .getPulseResponse() .getSlack().getBotToken(); if (token != null && !slackBlocks.isEmpty()) { MethodsClient client = Slack.getInstance().methods(token); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/SlackSignatureVerifier.java b/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/SlackSignatureVerifier.java index c9be9ed27..2d95c33bd 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/SlackSignatureVerifier.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/SlackSignatureVerifier.java @@ -30,7 +30,6 @@ public boolean verifyRequest(String slackSignature, String timestamp, String req // Generate HMAC-SHA256 signature String secret = configuration.getApplication() - .getPulseResponse() .getSlack().getSigningSecret(); String computedSignature = "v0=" + hmacSha256(secret, baseString); diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index 72d611518..469d84a58 100755 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -97,14 +97,10 @@ check-ins: feedback: max-suggestions: 6 request-subject: "Feedback request" - notifications: - slack: - webhook-url: ${ SLACK_WEBHOOK_URL } - bot-token: ${ SLACK_BOT_TOKEN } - pulse-response: - slack: - signing-secret: ${ SLACK_PULSE_SIGNING_SECRET } - bot-token: ${ SLACK_PULSE_BOT_TOKEN } + slack: + webhook-url: ${ SLACK_WEBHOOK_URL } + bot-token: ${ SLACK_BOT_TOKEN } + signing-secret: ${ SLACK_SIGNING_SECRET } web-address: ${ WEB_ADDRESS } --- flyway: diff --git a/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java b/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java index fa7d0c0b5..c4d94aa70 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java @@ -556,7 +556,6 @@ void testCreateAPulseResponseFromSlack() { private String slackSignature(String timestamp, String rawBody) { String baseString = "v0:" + timestamp + ":" + rawBody; String secret = configuration.getApplication() - .getPulseResponse() .getSlack().getSigningSecret(); try { diff --git a/server/src/test/resources/application-test.yml b/server/src/test/resources/application-test.yml index c5aca006c..132a9b1a6 100644 --- a/server/src/test/resources/application-test.yml +++ b/server/src/test/resources/application-test.yml @@ -41,14 +41,10 @@ check-ins: application: google-api: delegated-user: test@objectcomputing.com - notifications: - slack: - webhook-url: https://bogus.objectcomputing.com/slack - bot-token: BOGUS_TOKEN - pulse-response: - slack: - signing-secret: BOGUS_SIGNING_SECRET - bot-token: BOGUS_TOKEN + slack: + webhook-url: https://bogus.objectcomputing.com/slack + bot-token: BOGUS_TOKEN + signing-secret: BOGUS_SIGNING_SECRET --- aes: key: BOGUS_TEST_KEY