File tree Expand file tree Collapse file tree 5 files changed +42
-2
lines changed
java/com/objectcomputing/checkins
notifications/social_media Expand file tree Collapse file tree 5 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ public static class ApplicationConfig {
3131 @ NotNull
3232 private GoogleApiConfig googleApi ;
3333
34+ @ NotNull
35+ private NotificationsConfig notifications ;
36+
3437 @ Getter
3538 @ Setter
3639 @ ConfigurationProperties ("feedback" )
@@ -66,5 +69,25 @@ public static class ScopeConfig {
6669 private String scopeForDirectoryApi ;
6770 }
6871 }
72+
73+ @ Getter
74+ @ Setter
75+ @ ConfigurationProperties ("notifications" )
76+ public static class NotificationsConfig {
77+
78+ @ NotNull
79+ private SlackConfig slack ;
80+
81+ @ Getter
82+ @ Setter
83+ @ ConfigurationProperties ("slack" )
84+ public static class SlackConfig {
85+ @ NotBlank
86+ private String webhookUrl ;
87+
88+ @ NotBlank
89+ private String botToken ;
90+ }
91+ }
6992 }
7093}
Original file line number Diff line number Diff line change 11package com .objectcomputing .checkins .notifications .social_media ;
22
3+ import com .objectcomputing .checkins .configuration .CheckInsConfiguration ;
34import io .micronaut .http .HttpRequest ;
45import io .micronaut .http .HttpResponse ;
56import io .micronaut .http .HttpStatus ;
@@ -16,9 +17,12 @@ public class SlackPoster {
1617 @ Inject
1718 private HttpClient slackClient ;
1819
20+ @ Inject
21+ private CheckInsConfiguration configuration ;
22+
1923 public HttpResponse post (String slackBlock ) {
2024 // See if we can have a webhook URL.
21- String slackWebHook = System . getenv ( "SLACK_WEBHOOK_URL" );
25+ String slackWebHook = configuration . getApplication (). getNotifications (). getSlack (). getWebhookUrl ( );
2226 if (slackWebHook != null ) {
2327 // POST it to Slack.
2428 BlockingHttpClient client = slackClient .toBlocking ();
Original file line number Diff line number Diff line change 11package com .objectcomputing .checkins .notifications .social_media ;
22
3+ import com .objectcomputing .checkins .configuration .CheckInsConfiguration ;
34import com .slack .api .model .block .LayoutBlock ;
45import com .slack .api .Slack ;
56import com .slack .api .methods .MethodsClient ;
1617import java .util .List ;
1718import java .io .IOException ;
1819
20+ import jnr .ffi .annotations .In ;
1921import org .slf4j .Logger ;
2022import org .slf4j .LoggerFactory ;
2123
@@ -24,8 +26,11 @@ public class SlackSearch {
2426 private static final Logger LOG = LoggerFactory .getLogger (SlackSearch .class );
2527 private static final String env = "SLACK_BOT_TOKEN" ;
2628
29+ @ Inject
30+ private CheckInsConfiguration configuration ;
31+
2732 public String findChannelId (String channelName ) {
28- String token = System . getenv ( env );
33+ String token = configuration . getApplication (). getNotifications (). getSlack (). getBotToken ( );
2934 if (token != null ) {
3035 try {
3136 MethodsClient client = Slack .getInstance ().methods (token );
Original file line number Diff line number Diff line change @@ -97,6 +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 }
100104 web-address : ${ WEB_ADDRESS }
101105---
102106flyway :
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ check-ins:
4141 application :
4242 google-api :
434344+ notifications :
45+ slack :
46+ webhook-url : https://bogus.objectcomputing.com/slack
47+ bot-token : BOGUS_TOKEN
4448---
4549aes :
4650 key : BOGUS_TEST_KEY
You can’t perform that action at this time.
0 commit comments