Skip to content
Merged
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feature/kakao-api
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -60,6 +61,8 @@ jobs:

export DB_PASSWORD='${{ secrets.DB_PASSWORD }}'
export DISCORD_TOKEN='${{ secrets.DISCORD_TOKEN }}'
export KAKAO_REST_API_KEY='${{ secrets.KAKAO_REST_API_KEY }}'
export KAKAO_EVENT_API_KEY='${{ secrets.KAKAO_EVENT_API_KEY }}'

nohup java -jar build/libs/workingdead-0.0.1-SNAPSHOT.jar > app.log 2>&1 &

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void addParticipant(String channelId, String memberId, String memberName)
return;
}

ParticipantRes pRes = participantService.add(voteId, memberName);
ParticipantRes pRes = participantService.add(voteId, null, memberName);
System.out.println("[Discord When:D] Participant added AFTER vote: " + memberName
+ " (discordId=" + memberId + ", participantId=" + pRes.id() + ")");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.workingdead.chatbot.kakao.client;

import java.util.List;

public interface KakaoChatClient {
List<KakaoChatUser> fetchChatUsers(String botGroupKey);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.workingdead.chatbot.kakao.client;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient;

import java.util.List;

@Component
public class KakaoChatClientImpl implements KakaoChatClient {

private final RestClient restClient;
private final String botId;

public KakaoChatClientImpl(
RestClient.Builder builder,
@Value("${kakao.bot-base-url}") String baseUrl,
@Value("${kakao.bot-id}") String botId,
@Value("${kakao.rest-api-key}") String restApiKey
) {
this.botId = botId;
this.restClient = builder
.baseUrl(baseUrl)
.defaultHeader(HttpHeaders.AUTHORIZATION, "KakaoAK " + restApiKey)
.defaultHeader(HttpHeaders.CONTENT_TYPE, "application/json")
.build();
}

@Override
public List<KakaoChatUser> fetchChatUsers(String botGroupKey) {
KakaoChatMembersResponse res = restClient.get()
.uri("/v2/bots/{botId}/group-chat-rooms/{botGroupKey}/members", botId, botGroupKey)
.retrieve()
.body(KakaoChatMembersResponse.class);

if (res == null || res.users() == null) return List.of();

return res.users().stream()
.map(KakaoChatUser::new) // botUserKey 그대로
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.workingdead.chatbot.kakao.client;

import java.util.List;

public record KakaoChatMembersResponse(List<String> users) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.workingdead.chatbot.kakao.client;

public record KakaoChatUser(String botUserKey) {

}
Loading