-
Notifications
You must be signed in to change notification settings - Fork 3
refactor : 알림 데이터 추가 및 관련 문서 작성 #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough이 변경사항은 커뮤니티 투표 및 댓글 서비스에서 알림 생성 로직의 try-catch 블록을 제거하고, 알림 페이로드에 voterId 등 추가 정보를 포함하도록 확장하였습니다. 또한, 알림 타입과 페이로드 구조가 세분화되고, 알림 응답 객체에 메시지 및 리다이렉트 URL 필드가 추가되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Service
participant DomainService
participant NotificationExecutor
participant NotificationSystem
User->>Service: 댓글/투표 요청
Service->>DomainService: 알림 이벤트 생성 요청
DomainService->>NotificationExecutor: 비동기 알림 생성
NotificationExecutor->>NotificationSystem: 알림 생성 (voterId 등 추가 정보 포함)
NotificationSystem-->>User: WebSocket으로 알림 전송
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/org/ezcode/codetest/presentation/notification/NotificationController.java (1)
33-42: API 문서 개선이 잘 되었으나 하드코딩된 링크 개선을 고려해보세요.WebSocket 기반 알림 전달 방식에 대한 상세한 설명이 추가되어 API 사용법이 명확해졌습니다. 다만, Notion 링크가 하드코딩되어 있어 링크 변경 시 유지보수가 어려울 수 있습니다.
설정 파일이나 상수로 관리하는 것을 고려해보세요.
+ // application.yml에 추가 + notification: + documentation: + url: "https://www.notion.so/teamsparta/1-5-2002dc3ef51481e7afbec86e90d0010e?p=2232dc3ef51480638fd9eecc3b90a0fc&pm=s" - 자세한 내용은 다음 [링크](https://www.notion.so/teamsparta/1-5-2002dc3ef51481e7afbec86e90d0010e?p=2232dc3ef51480638fd9eecc3b90a0fc&pm=s) 참고 + 자세한 내용은 다음 [링크](%s) 참고
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
src/main/java/org/ezcode/codetest/application/community/service/DiscussionVoteService.java(1 hunks)src/main/java/org/ezcode/codetest/application/community/service/ReplyService.java(1 hunks)src/main/java/org/ezcode/codetest/application/community/service/ReplyVoteService.java(1 hunks)src/main/java/org/ezcode/codetest/application/notification/enums/NotificationType.java(1 hunks)src/main/java/org/ezcode/codetest/application/notification/event/payload/DiscussionVotePayload.java(1 hunks)src/main/java/org/ezcode/codetest/application/notification/event/payload/ReplyCreatePayload.java(1 hunks)src/main/java/org/ezcode/codetest/application/notification/event/payload/ReplyVotePayload.java(1 hunks)src/main/java/org/ezcode/codetest/domain/community/model/entity/Reply.java(2 hunks)src/main/java/org/ezcode/codetest/domain/community/service/DiscussionVoteDomainService.java(1 hunks)src/main/java/org/ezcode/codetest/domain/community/service/ReplyDomainService.java(1 hunks)src/main/java/org/ezcode/codetest/domain/community/service/ReplyVoteDomainService.java(1 hunks)src/main/java/org/ezcode/codetest/infrastructure/notification/dto/NotificationResponse.java(2 hunks)src/main/java/org/ezcode/codetest/presentation/notification/NotificationController.java(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: chat26666
PR: ezcode-my/backend#37
File: src/main/java/org/ezcode/codetest/infrastructure/elasticsearch/repository/ProblemElasticsearchRepositoryDsl.java:10-10
Timestamp: 2025-06-06T19:56:27.759Z
Learning: When user chat26666 mentions that code was implemented in a previous PR but explanation was missing, they may submit a follow-up PR just to add documentation/explanation without the actual implementation code.
Learnt from: NCookies
PR: ezcode-my/backend#69
File: src/test/java/org/ezcode/codetest/domain/community/service/DiscussionVoteDomainServiceTest.java:115-119
Timestamp: 2025-06-17T11:22:40.147Z
Learning: `VoteResult`의 `prevVoteType` 필드는 UP 요청이 반복될 때 알림 도배를 방지하기 위한 목적으로 사용됩니다. 투표 취소(NONE) 시나리오에서는 알림 도배 방지 로직이 필요하지 않으므로, `prevVoteType`을 실제 이전 값으로 설정할 필요가 없습니다.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (16)
src/main/java/org/ezcode/codetest/application/notification/event/payload/ReplyVotePayload.java (1)
6-6: 알림 페이로드 확장이 적절합니다.투표자 ID 필드 추가로 알림 데이터의 정확성과 완성도가 향상되었습니다. 기존 voterNickname과 함께 voterId를 제공함으로써 더 정확한 사용자 식별이 가능해집니다.
src/main/java/org/ezcode/codetest/domain/community/service/DiscussionVoteDomainService.java (1)
58-58: 페이로드 생성 로직 업데이트가 올바릅니다.DiscussionVotePayload에 추가된 voterId 필드를 적절히 채우도록 수정되었습니다. 투표자의 ID 정보가 알림 이벤트에 포함되어 더 풍부한 알림 데이터를 제공할 수 있습니다.
src/main/java/org/ezcode/codetest/application/notification/event/payload/DiscussionVotePayload.java (1)
6-6: 일관성 있는 페이로드 확장입니다.ReplyVotePayload와 동일한 방식으로 voterId 필드가 추가되어, 알림 시스템 전반에 걸쳐 일관성 있는 데이터 구조를 유지하고 있습니다.
src/main/java/org/ezcode/codetest/application/community/service/ReplyVoteService.java (1)
53-58: ReplyVoteService.afterVote 예외 전파 우려 불필요 확인
NotificationExecutor.execute()가 내부에서 모든 예외를 잡아(catch (Exception)), 새로운 트랜잭션(REQUIRES_NEW)으로 알림 처리 중 발생한 예외를 로깅만 하고 무시하도록 설계되어 있습니다.
따라서 ReplyVoteService.afterVote에서 별도의 try-catch를 추가하지 않아도 알림 실패가 메인 투표 트랜잭션에 영향을 주지 않습니다.검토 대상 위치:
- org/ezcode/codetest/application/community/service/ReplyVoteService.java:53–58
- org/ezcode/codetest/application/notification/service/NotificationExecutor.java:22–36
이상으로 추가 수정 없이도 예외 처리 전략이 의도대로 동작함을 확인했습니다.
src/main/java/org/ezcode/codetest/domain/community/model/entity/Reply.java (2)
96-96: 코드 정리가 적절합니다.불필요한 주석이 제거되어 코드가 더 깔끔해졌습니다.
112-115: 유용한 유틸리티 메서드 추가입니다.부모 댓글 ID를 반환하는 메서드가 추가되어 댓글 계층 구조를 더 쉽게 파악할 수 있습니다. null 체크도 적절히 구현되었습니다.
src/main/java/org/ezcode/codetest/application/community/service/DiscussionVoteService.java (1)
52-57: NotificationExecutor에서 예외 처리 자동화 확인됨
NotificationExecutor.execute(...)내부에try-catch(Exception)블록이 있어
notificationsEventSupplier.get()호출 중- 각
notificationEventService.notify(event)실행 중발생하는 예외를 모두 로깅(
log.error)하고 swallow 처리하므로,
DiscussionVoteService에서 별도의 예외 처리 블록을 제거해도 무방합니다.추가 조치 불필요합니다.
src/main/java/org/ezcode/codetest/application/community/service/ReplyService.java (1)
51-55: 코드 간소화 개선 확인알림 생성 로직이 함수형 프로그래밍 스타일로 간소화되어 가독성이 향상되었습니다. 하지만 다른 서비스와 마찬가지로 예외 처리가
NotificationExecutor에 위임되므로, 실행기에서 적절한 예외 처리가 이루어지는지 확인이 필요합니다.src/main/java/org/ezcode/codetest/domain/community/service/ReplyVoteDomainService.java (1)
63-63: 알림 페이로드 정보 확장 개선투표자 ID를 페이로드에 추가하여 알림 데이터가 더욱 풍부해졌습니다. 이를 통해 알림 시스템에서 더 상세한 정보를 활용할 수 있게 되었습니다.
src/main/java/org/ezcode/codetest/application/notification/event/payload/ReplyCreatePayload.java (1)
6-10: 댓글 알림 페이로드 구조 개선댓글 알림 페이로드에 부모 댓글 ID, 작성자 정보, 콘텐츠 등의 필드가 추가되어 알림 시스템이 더욱 상세한 정보를 제공할 수 있게 되었습니다. 특히
parentReplyId를 통해 일반 댓글과 대댓글을 구분할 수 있어 알림 타입 세분화에 도움이 됩니다.src/main/java/org/ezcode/codetest/application/notification/enums/NotificationType.java (1)
8-9: 알림 타입 세분화 개선
COMMUNITY_REPLY를 토론 댓글과 대댓글로 구분하여 사용자에게 더 명확한 알림 메시지를 제공할 수 있게 되었습니다. 각각의 메시지가 명확하고 한국어로 잘 작성되어 있으며, 리다이렉트 URL도 적절히 설정되어 있습니다.src/main/java/org/ezcode/codetest/infrastructure/notification/dto/NotificationResponse.java (2)
15-17: 새로운 필드 추가가 적절하게 구현되었습니다.
message와redirectUrl필드 추가로 클라이언트에서 알림 메시지와 리다이렉트 URL을 직접 받을 수 있게 되어 사용성이 향상되었습니다.
32-33: 확인 완료:NotificationTypeenum에 Getter 메서드가 자동 생성되어 있습니다
- src/main/java/org/ezcode/codetest/application/notification/enums/NotificationType.java 에
@Getter어노테이션이 적용되어 있어
getMessage()및getRedirectUrl()메서드가 Lombok에 의해 자동으로 생성됩니다.- 따라서
document.getNotificationType().getMessage()와
getRedirectUrl()호출은 정상입니다.src/main/java/org/ezcode/codetest/domain/community/service/ReplyDomainService.java (3)
110-111: 변수 추출로 가독성이 향상되었습니다.
parentReplyId와author변수를 명시적으로 추출하여 코드의 의도가 더 명확해졌습니다.
125-127: Reply.getParentReplyId() 메서드 확인됨
src/main/java/org/ezcode/codetest/domain/community/model/entity/Reply.java파일 112행에public Long getParentReplyId() { … }가 정의되어 있어, 알림 타입 구분 로직에 필요한 메서드가 정상 구현되어 있습니다.
해당 이슈는 해결되었으므로 변경사항을 승인합니다.
116-119: ReplyCreatePayload 생성자 필드 확인 완료
src/main/java/org/ezcode/codetest/application/notification/event/payload/ReplyCreatePayload.java레코드 정의에서parentReplyId,authorId,authorNickname필드가 모두 포함되어 있으므로 추가 수정은 필요 없습니다.
작업 내용
참고 사항
Summary by CodeRabbit
New Features
Enhancements
Documentation