Skip to content

Commit 7cecfb9

Browse files
authored
Merge pull request #2941 from objectcomputing/bugfix-2933/fix-kudos-urls-and-channels
Switched to a different Slack API to gather channel information
2 parents fe670b3 + 8566a48 commit 7cecfb9

File tree

1 file changed

+7
-10
lines changed
  • server/src/main/java/com/objectcomputing/checkins/services/slack

1 file changed

+7
-10
lines changed

server/src/main/java/com/objectcomputing/checkins/services/slack/SlackSearch.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.objectcomputing.checkins.services.slack;
22

33
import com.objectcomputing.checkins.configuration.CheckInsConfiguration;
4+
import com.slack.api.methods.request.conversations.ConversationsInfoRequest;
5+
import com.slack.api.methods.response.conversations.ConversationsInfoResponse;
46
import com.slack.api.model.block.LayoutBlock;
57
import com.slack.api.Slack;
68
import com.slack.api.methods.MethodsClient;
@@ -63,17 +65,12 @@ public String findChannelName(String channelId) {
6365
if (token != null) {
6466
try {
6567
MethodsClient client = Slack.getInstance().methods(token);
66-
ConversationsListResponse response = client.conversationsList(
67-
ConversationsListRequest.builder().build()
68-
);
68+
ConversationsInfoResponse conversationsInfoResponse = client.conversationsInfo(ConversationsInfoRequest.builder().channel(channelId).build());
6969

70-
if (response.isOk()) {
71-
for (Conversation conversation: response.getChannels()) {
72-
LOG.trace("Found conversation: {}", conversation);
73-
if (conversation.getId().equals(channelId)) {
74-
return conversation.getName();
75-
}
76-
}
70+
if (conversationsInfoResponse.isOk()) {
71+
Conversation channel = conversationsInfoResponse.getChannel();
72+
LOG.trace("Found conversation: {}", channel);
73+
return channel.getName();
7774
}
7875
} catch(IOException e) {
7976
LOG.error("SlackSearch.findChannelName: " + e.toString());

0 commit comments

Comments
 (0)