Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public static class ApplicationConfig {
private GoogleApiConfig googleApi;

@NotNull
private NotificationsConfig notifications;

@NotNull
private PulseResponseConfig pulseResponse;
private SlackConfig slack;

@Getter
@Setter
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 4 additions & 8 deletions server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 4 additions & 8 deletions server/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading