feat: Send message when a user registers or creates a group#386
feat: Send message when a user registers or creates a group#386
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds Discord notifications for user registration and study group creation by introducing a new DiscordWebhookService and invoking it in relevant service methods.
- Inject and call
DiscordWebhookServiceinUserService,OAuth2Service, andStudyGroupService - Implement
DiscordWebhookServiceto post messages to a configured webhook URL
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main/java/com/gamzabat/algohub/feature/user/service/UserService.java | Added webhook call after user registration |
| src/main/java/com/gamzabat/algohub/auth/service/OAuth2Service.java | Added webhook call after GitHub-based registration |
| src/main/java/com/gamzabat/algohub/feature/group/studygroup/service/StudyGroupService.java | Added webhook call after study group creation |
| src/main/java/com/gamzabat/algohub/common/logging/DiscordWebhookService.java | New service to send Discord webhook notifications |
Comments suppressed due to low confidence (3)
src/main/java/com/gamzabat/algohub/feature/user/service/UserService.java:100
- [nitpick] The literal "SignUp" could be inconsistent or typo-prone; consider defining a constant or enum for registration types to ensure consistency.
webhookService.sendRegisterMessage(user.getNickname(), "SignUp", user.getId());
src/main/java/com/gamzabat/algohub/auth/service/OAuth2Service.java:85
- [nitpick] The literal "Github" should align with proper branding ("GitHub") and be centralized to avoid typos; consider using a shared constant.
webhookService.sendRegisterMessage(newUser.getNickname(), "Github", newUser.getId());
src/main/java/com/gamzabat/algohub/common/logging/DiscordWebhookService.java:23
- The new service methods lack unit or integration tests for both success and failure scenarios; consider adding tests for payload formatting and error handling.
public void sendRegisterMessage(String username, String type, Long sid) {
| saveProfileImage(profileImage, user); | ||
| log.info("success to register user_id={}", user.getId()); | ||
|
|
||
| webhookService.sendRegisterMessage(user.getNickname(), "SignUp", user.getId()); |
There was a problem hiding this comment.
[nitpick] Webhook notifications are invoked in multiple services (UserService, OAuth2Service, StudyGroupService); extracting this logic into a shared utility or AOP advice could reduce duplication.
| private final RestTemplate restTemplate; | ||
|
|
||
| public void sendRegisterMessage(String username, String type, Long sid) { | ||
| String content = username + " 님이 " + type + " 방식으로 " + sid + "번째로 회원가입 하셨습니다!! 🎉"; |
There was a problem hiding this comment.
[nitpick] Hardcoding localized strings in code can hinder future localization; consider externalizing message templates or using a message source for maintainability.
| if (!StringUtils.hasText(webhookUrl)) { | ||
| log.debug("No webhook url provided"); | ||
| return; |
There was a problem hiding this comment.
webhook-prod.yml에만 노티 주소 넣었습니다.
나머지 스테이지면 무시하려고 한거고, 다른 구현 프랙티스는
스테이지마다 Bean을 다르게 생성하는건데 간단한 방법으로..
Test Results 18 files 18 suites 5s ⏱️ Results for commit 223e2f9. ♻️ This comment has been updated with latest results. |
|
걍 머지할게요 |
📌 Related Issue
close be-30
🚀 Description