Skip to content

Conversation

@NCookies
Copy link
Collaborator

@NCookies NCookies commented Jul 1, 2025

작업 내용

  • swagger에 알림 관련 설명 추가 및 링크 첨부
    • 데이터 사용 용도와 실제 예시 데이터 등이 작성되어 있음
  • 알림 데이터 추가
    • 알림에 필요한 데이터들을 추가로 삽입함

참고 사항

Summary by CodeRabbit

  • New Features

    • 알림 응답에 메시지와 리다이렉트 URL 정보가 추가되었습니다.
    • 답글 엔티티에 부모 답글 ID를 조회할 수 있는 기능이 추가되었습니다.
  • Enhancements

    • 알림 타입이 기존 단일 답글 알림에서, 게시글 답글 알림과 대댓글 알림으로 세분화되었습니다.
    • 알림 관련 페이로드에 작성자, 부모 답글, 투표자 등 더 많은 정보가 포함되어 알림의 상세도가 향상되었습니다.
  • Documentation

    • 알림 목록 조회 API의 Swagger/OpenAPI 설명이 더욱 상세하게 보완되었습니다.

@NCookies NCookies self-assigned this Jul 1, 2025
@NCookies NCookies added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

Walkthrough

이 변경사항은 커뮤니티 투표 및 댓글 서비스에서 알림 생성 로직의 try-catch 블록을 제거하고, 알림 페이로드에 voterId 등 추가 정보를 포함하도록 확장하였습니다. 또한, 알림 타입과 페이로드 구조가 세분화되고, 알림 응답 객체에 메시지 및 리다이렉트 URL 필드가 추가되었습니다.

Changes

파일/경로 요약 변경 요약
.../application/community/service/DiscussionVoteService.java
.../ReplyVoteService.java
.../ReplyService.java
알림 생성 비동기 작업 내 try-catch 블록 제거, 예외 미처리로 변경
.../application/notification/enums/NotificationType.java COMMUNITY_REPLY enum 삭제, COMMUNITY_DISCUSSION_REPLY 및 COMMUNITY_CHILD_REPLY로 세분화
.../application/notification/event/payload/DiscussionVotePayload.java
.../ReplyVotePayload.java
voterId(Long) 필드 추가
.../application/notification/event/payload/ReplyCreatePayload.java parentReplyId, authorId, authorNickname, content 필드 추가 및 순서 변경
.../domain/community/model/entity/Reply.java getParentReplyId() 메소드 추가
.../domain/community/service/DiscussionVoteDomainService.java
.../ReplyVoteDomainService.java
알림 페이로드 생성 시 voterId 추가
.../domain/community/service/ReplyDomainService.java 알림 페이로드에 parentReplyId, authorId, authorNickname 등 추가 및 알림 타입 조건 분기
.../infrastructure/notification/dto/NotificationResponse.java message, redirectUrl 필드 추가 및 from() 팩토리 메소드 수정
.../presentation/notification/NotificationController.java 알림 목록 조회 API의 Swagger 설명을 상세하게 수정

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으로 알림 전송
Loading

Possibly related PRs

Suggested reviewers

  • minjee2758
  • pokerbearkr
  • chat26666
  • thezz9

Poem

🐇
알림에 담긴 이야기,
voterId도 함께 뛰놀지!
try-catch는 안녕,
페이로드는 더 풍성!
토끼 귀 쫑긋 세우고,
새 알림 기다려요,
코드를 타고 hop hop hop!

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between ed5ccb1 and 630ff0a.

📒 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: 새로운 필드 추가가 적절하게 구현되었습니다.

messageredirectUrl 필드 추가로 클라이언트에서 알림 메시지와 리다이렉트 URL을 직접 받을 수 있게 되어 사용성이 향상되었습니다.


32-33: 확인 완료: NotificationType enum에 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: 변수 추출로 가독성이 향상되었습니다.

parentReplyIdauthor 변수를 명시적으로 추출하여 코드의 의도가 더 명확해졌습니다.


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 필드가 모두 포함되어 있으므로 추가 수정은 필요 없습니다.

@NCookies NCookies merged commit 4caaf35 into dev Jul 2, 2025
2 checks passed
@NCookies NCookies deleted the refactor/notification-refact branch July 2, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants