Skip to content

Commit e2c88a5

Browse files
committed
Combine the notifications and pulse-response configurations into a single slack configuration.
1 parent 25a2caa commit e2c88a5

File tree

6 files changed

+18
-52
lines changed

6 files changed

+18
-52
lines changed

server/src/main/java/com/objectcomputing/checkins/configuration/CheckInsConfiguration.java

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ public static class ApplicationConfig {
3232
private GoogleApiConfig googleApi;
3333

3434
@NotNull
35-
private NotificationsConfig notifications;
36-
37-
@NotNull
38-
private PulseResponseConfig pulseResponse;
35+
private SlackConfig slack;
3936

4037
@Getter
4138
@Setter
@@ -75,42 +72,16 @@ public static class ScopeConfig {
7572

7673
@Getter
7774
@Setter
78-
@ConfigurationProperties("notifications")
79-
public static class NotificationsConfig {
80-
81-
@NotNull
82-
private SlackConfig slack;
83-
84-
@Getter
85-
@Setter
86-
@ConfigurationProperties("slack")
87-
public static class SlackConfig {
88-
@NotBlank
89-
private String webhookUrl;
90-
91-
@NotBlank
92-
private String botToken;
93-
}
94-
}
95-
96-
@Getter
97-
@Setter
98-
@ConfigurationProperties("pulse-response")
99-
public static class PulseResponseConfig {
100-
101-
@NotNull
102-
private SlackConfig slack;
75+
@ConfigurationProperties("slack")
76+
public static class SlackConfig {
77+
@NotBlank
78+
private String webhookUrl;
10379

104-
@Getter
105-
@Setter
106-
@ConfigurationProperties("slack")
107-
public static class SlackConfig {
108-
@NotBlank
109-
private String signingSecret;
80+
@NotBlank
81+
private String botToken;
11082

111-
@NotBlank
112-
private String botToken;
113-
}
83+
@NotBlank
84+
private String signingSecret;
11485
}
11586
}
11687
}

server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackPoster.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public class SlackPoster {
2121
private CheckInsConfiguration configuration;
2222

2323
public HttpResponse post(String slackBlock) {
24-
// See if we can have a webhook URL.
25-
String slackWebHook = configuration.getApplication().getNotifications().getSlack().getWebhookUrl();
24+
// See if we have a webhook URL.
25+
String slackWebHook = configuration.getApplication()
26+
.getSlack().getWebhookUrl();
2627
if (slackWebHook != null) {
2728
// POST it to Slack.
2829
BlockingHttpClient client = slackClient.toBlocking();

server/src/main/java/com/objectcomputing/checkins/notifications/social_media/SlackSearch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public SlackSearch(CheckInsConfiguration checkInsConfiguration) {
3232
}
3333

3434
public String findChannelId(String channelName) {
35-
String token = configuration.getApplication().getNotifications().getSlack().getBotToken();
35+
String token = configuration.getApplication().getSlack().getBotToken();
3636
if (token != null) {
3737
try {
3838
MethodsClient client = Slack.getInstance().methods(token);
@@ -57,7 +57,7 @@ public String findChannelId(String channelName) {
5757
}
5858

5959
public String findUserId(String userEmail) {
60-
String token = configuration.getApplication().getNotifications().getSlack().getBotToken();
60+
String token = configuration.getApplication().getSlack().getBotToken();
6161
if (token != null) {
6262
try {
6363
MethodsClient client = Slack.getInstance().methods(token);

server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseSlackCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public boolean send(String triggerId) {
3535

3636
// See if we have a token.
3737
String token = configuration.getApplication()
38-
.getPulseResponse()
3938
.getSlack().getBotToken();
4039
if (token != null && !slackBlocks.isEmpty()) {
4140
MethodsClient client = Slack.getInstance().methods(token);

server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/SlackSignatureVerifier.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public boolean verifyRequest(String slackSignature, String timestamp, String req
3030

3131
// Generate HMAC-SHA256 signature
3232
String secret = configuration.getApplication()
33-
.getPulseResponse()
3433
.getSlack().getSigningSecret();
3534
String computedSignature = "v0=" + hmacSha256(secret, baseString);
3635

server/src/main/resources/application.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,10 @@ check-ins:
9797
feedback:
9898
max-suggestions: 6
9999
request-subject: "Feedback request"
100-
notifications:
101-
slack:
102-
webhook-url: ${ SLACK_WEBHOOK_URL }
103-
bot-token: ${ SLACK_BOT_TOKEN }
104-
pulse-response:
105-
slack:
106-
signing-secret: ${ SLACK_PULSE_SIGNING_SECRET }
107-
bot-token: ${ SLACK_PULSE_BOT_TOKEN }
100+
slack:
101+
webhook-url: ${ SLACK_WEBHOOK_URL }
102+
bot-token: ${ SLACK_BOT_TOKEN }
103+
signing-secret: ${ SLACK_SIGNING_SECRET }
108104
web-address: ${ WEB_ADDRESS }
109105
---
110106
flyway:

0 commit comments

Comments
 (0)