Skip to content

Commit 719d807

Browse files
authored
Merge pull request #2867 from objectcomputing/feature-2854/slack-integration-per-deployment
Feature 2854/slack integration per deployment
2 parents 9047651 + f1a0f6a commit 719d807

File tree

8 files changed

+23
-62
lines changed

8 files changed

+23
-62
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public SlackSearch(CheckInsConfiguration checkInsConfiguration) {
3434
}
3535

3636
public String findChannelId(String channelName) {
37-
String token = configuration.getApplication().getNotifications().getSlack().getBotToken();
37+
String token = configuration.getApplication().getSlack().getBotToken();
3838
if (token != null) {
3939
try {
4040
MethodsClient client = Slack.getInstance().methods(token);
@@ -59,7 +59,7 @@ public String findChannelId(String channelName) {
5959
}
6060

6161
public String findUserId(String userEmail) {
62-
String token = configuration.getApplication().getNotifications().getSlack().getBotToken();
62+
String token = configuration.getApplication().getSlack().getBotToken();
6363
if (token != null) {
6464
try {
6565
MethodsClient client = Slack.getInstance().methods(token);
@@ -80,7 +80,7 @@ public String findUserId(String userEmail) {
8080
}
8181

8282
public String findUserEmail(String userId) {
83-
String token = configuration.getApplication().getNotifications().getSlack().getBotToken();
83+
String token = configuration.getApplication().getSlack().getBotToken();
8484
if (token != null) {
8585
try {
8686
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:

server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ void testCreateAPulseResponseFromSlack() {
556556
private String slackSignature(String timestamp, String rawBody) {
557557
String baseString = "v0:" + timestamp + ":" + rawBody;
558558
String secret = configuration.getApplication()
559-
.getPulseResponse()
560559
.getSlack().getSigningSecret();
561560

562561
try {

server/src/test/resources/application-test.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,10 @@ check-ins:
4141
application:
4242
google-api:
4343
delegated-user: [email protected]
44-
notifications:
45-
slack:
46-
webhook-url: https://bogus.objectcomputing.com/slack
47-
bot-token: BOGUS_TOKEN
48-
pulse-response:
49-
slack:
50-
signing-secret: BOGUS_SIGNING_SECRET
51-
bot-token: BOGUS_TOKEN
44+
slack:
45+
webhook-url: https://bogus.objectcomputing.com/slack
46+
bot-token: BOGUS_TOKEN
47+
signing-secret: BOGUS_SIGNING_SECRET
5248
---
5349
aes:
5450
key: BOGUS_TEST_KEY

0 commit comments

Comments
 (0)