Skip to content

[REFACTOR] : 알림 리팩토링#277

Merged
yooooonshine merged 6 commits intodevelopfrom
feature/276-refactor-alaram
Nov 23, 2025
Merged

[REFACTOR] : 알림 리팩토링#277
yooooonshine merged 6 commits intodevelopfrom
feature/276-refactor-alaram

Conversation

@yooooonshine
Copy link
Contributor

@yooooonshine yooooonshine commented Nov 23, 2025

개요

작업사항

  • 파생 포스트 생성 시 알람 가도록 추가
  • 좋아요 시 알람가도록 추가
  • 알람 내용 수정
  • 응답에 senderId 추가

Summary by CodeRabbit

  • New Features

    • 게시글 좋아요 시 작성자에게 실시간 알림 발송 기능 추가
    • 2차 창작물 생성 시 원본 게시글 작성자에게 자동 알림 발송
    • 알림 응답에 발송자 정보 포함으로 알림 수신자 확인 가능
  • Improvements

    • 알림 메시지 문구 개선 및 정확도 향상

✏️ Tip: You can customize this high-level summary in your review settings.

@yooooonshine yooooonshine linked an issue Nov 23, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

Warning

Rate limit exceeded

@yooooonshine has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b021c3f and 1c6a89a.

📒 Files selected for processing (3)
  • src/main/java/hanium/modic/backend/domain/notification/enums/NotificationType.java (3 hunks)
  • src/test/java/hanium/modic/backend/domain/follow/service/FollowMockingServiceTest.java (0 hunks)
  • src/test/java/hanium/modic/backend/domain/post/service/AiDerivedPostServiceTest.java (5 hunks)

요약

이 변경사항은 알림 시스템에 새로운 기능을 추가합니다. GetNotificationsResponse DTO에 senderId 필드를 추가하고, NotificationType 열거형에 LIKED 타입을 도입하며, 게시물 좋아요와 파생 게시물 생성 시 알림 전송 기능을 구현합니다.

변경사항

코호트 / 파일(들) 변경 요약
알림 응답 DTO 확장
src/main/java/hanium/modic/backend/domain/notification/dto/GetNotificationsResponse.java
senderId 필드를 GetNotificationsResponse 레코드에 추가하고, of() 정적 팩토리 메서드에서 payload.senderId()를 포함하도록 업데이트
알림 타입 및 메시지 업데이트
src/main/java/hanium/modic/backend/domain/notification/enums/NotificationType.java
새로운 LIKED 열거형 상수 추가, 기존 알림 메시지 텍스트 업데이트 (POST_REVIEWED, FOLLOWED, DERIVED_POST_CREATED 등)
파생 게시물 서비스에 알림 기능 추가
src/main/java/hanium/modic/backend/domain/post/service/AiDerivedPostService.java
NotificationServiceUserEntityRepository 의존성 추가, 파생 게시물 생성 후 원본 게시물 소유자에게 알림 전송 로직 구현
좋아요 서비스에 알림 기능 추가
src/main/java/hanium/modic/backend/domain/postLike/service/PostLikeService.java
NotificationServiceUserEntityRepository 의존성 추가, 좋아요 추가 후 게시물 소유자에게 LIKED 타입 알림 전송 로직 구현

시퀀스 다이어그램

sequenceDiagram
    actor User as 사용자
    participant PostLikeService as PostLikeService
    participant UserRepo as UserEntityRepository
    participant LikeRepo as PostLikeRepository
    participant NotificationService as NotificationService
    
    User ->> PostLikeService: addLike(postId, userId)
    PostLikeService ->> UserRepo: findById(userId)
    UserRepo -->> PostLikeService: UserEntity
    PostLikeService ->> LikeRepo: save(PostLike)
    LikeRepo -->> PostLikeService: PostLike
    PostLikeService ->> NotificationService: sendNotification(LIKED, payload)
    NotificationService -->> PostLikeService: 알림 전송 완료
    PostLikeService -->> User: 좋아요 추가 및 알림 발송 완료
Loading
sequenceDiagram
    actor User as 사용자
    participant AiDerivedPostService as AiDerivedPostService
    participant UserRepo as UserEntityRepository
    participant PostRepo as PostRepository
    participant NotificationService as NotificationService
    
    User ->> AiDerivedPostService: createAiDerivedPost(userId, postId, ...)
    AiDerivedPostService ->> UserRepo: findById(userId)
    UserRepo -->> AiDerivedPostService: UserEntity
    AiDerivedPostService ->> PostRepo: save(DerivedPost)
    PostRepo -->> AiDerivedPostService: DerivedPost
    AiDerivedPostService ->> NotificationService: sendNotification(DERIVED_POST_CREATED, payload)
    NotificationService -->> AiDerivedPostService: 알림 전송 완료
    AiDerivedPostService -->> User: 파생 게시물 생성 및 알림 발송 완료
Loading

예상 코드 리뷰 노력

🎯 3 (중간 복잡도) | ⏱️ ~20분

  • NotificationType.java: 메시지 텍스트 변경의 정확성 및 기존 기능과의 호환성 확인 필요
  • AiDerivedPostService.javaPostLikeService.java: 새로운 의존성 주입, 사용자 검증 로직, 알림 전송 경로의 트랜잭션 안전성과 오류 처리 검증 필요
  • GetNotificationsResponse.java: senderId 필드 추가가 기존 직렬화/역직렬화 및 클라이언트 호환성에 미치는 영향 확인

관련 PR

🐰 좋아요를 받으면 알림이 울려요,
파생 게시물도 알려주며,
senderId는 누가 보냈는지,
알림 시스템이 더욱 영리해졌네요!
사용자 경험의 새로운 시작~ 🔔

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경사항을 명확하게 설명합니다. '알림 리팩토링'은 파생 포스트 알림, 좋아요 알림, 응답 필드 추가 등 모든 변경사항의 핵심을 포함합니다.
Description check ✅ Passed PR 설명이 필수 템플릿 섹션(개요, 작업사항)을 완벽하게 따르고 있으며, 연관 이슈(#276)를 명시하고 구체적인 작업 항목들을 나열했습니다.
Linked Issues check ✅ Passed PR은 연관 이슈 #276의 알림 리팩토링 목표를 충족합니다. 파생 포스트 알림 추가, 좋아요 알림 추가, 알림 내용 수정, senderId 응답 추가 등 모든 구현 항목이 요구사항과 일치합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 알림 시스템 리팩토링이라는 명확한 범위 내에 있습니다. DTO 필드 추가, 알림 유형 수정, 알림 서비스 연동 등이 모두 알림 기능과 직접 관련이 있습니다.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 1

🧹 Nitpick comments (2)
src/main/java/hanium/modic/backend/domain/postLike/service/PostLikeService.java (1)

80-89: 분산 락 내부에서 알림 생성을 고려하세요.

현재 알림 생성이 분산 락 내부에서 동기적으로 실행되어 좋아요와 알림의 원자성을 보장합니다. 그러나 이로 인해 락을 보유하는 시간이 길어져 처리량에 영향을 줄 수 있습니다.

만약 알림 생성 지연이 성능 문제를 일으킨다면, TransactionSynchronization을 사용하여 트랜잭션 커밋 후 알림을 비동기로 전송하는 것을 고려해보세요. (단, 이 경우 원자성 보장이 약화됩니다)

src/main/java/hanium/modic/backend/domain/notification/enums/NotificationType.java (1)

88-95: 제목과 본문을 구별하는 것을 고려하세요.

현재 LIKED 알림의 제목과 본문이 동일한 메시지를 사용하고 있습니다. 사용자 경험 향상을 위해 제목은 간결하게, 본문은 상세하게 작성하는 것을 고려해보세요.

예시:

  • 제목: "새로운 좋아요"
  • 본문: "님이 '{게시글제목}' 게시글에 좋아요를 눌렀습니다."
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6bb2165 and b021c3f.

📒 Files selected for processing (4)
  • src/main/java/hanium/modic/backend/domain/notification/dto/GetNotificationsResponse.java (2 hunks)
  • src/main/java/hanium/modic/backend/domain/notification/enums/NotificationType.java (3 hunks)
  • src/main/java/hanium/modic/backend/domain/post/service/AiDerivedPostService.java (4 hunks)
  • src/main/java/hanium/modic/backend/domain/postLike/service/PostLikeService.java (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (7)
src/main/java/hanium/modic/backend/domain/postLike/service/PostLikeService.java (2)

4-4: LGTM!

알림 기능을 위한 의존성 추가가 적절하게 구성되었습니다.

Also applies to: 16-19, 45-46


57-58: LGTM!

분산 락 획득 전 사용자 존재 여부를 미리 검증하여 불필요한 락 획득을 방지하는 좋은 설계입니다.

src/main/java/hanium/modic/backend/domain/notification/enums/NotificationType.java (1)

52-52: LGTM!

알림 메시지가 더 명확하고 일관성 있게 개선되었습니다.

Also applies to: 64-64, 76-76, 82-82

src/main/java/hanium/modic/backend/domain/post/service/AiDerivedPostService.java (3)

15-17: LGTM!

알림 기능 및 사용자 검증을 위한 의존성이 올바르게 추가되었습니다.

Also applies to: 24-25, 33-33, 52-52, 55-55, 58-58


81-82: LGTM!

파생 포스트 생성 전 사용자 존재 여부를 조기에 검증하여 불필요한 작업을 방지하는 좋은 설계입니다.


171-179: LGTM!

파생 포스트 생성 시 원작자에게 알림을 전송하는 로직이 올바르게 구현되었습니다. 알림 페이로드의 수신자와 발신자 정보가 정확합니다.

src/main/java/hanium/modic/backend/domain/notification/dto/GetNotificationsResponse.java (1)

16-16: 모든 알림 타입에서 senderId 제공 확인 완료

검증 결과, 모든 알림 타입에서 senderId를 올바르게 제공하고 있습니다.

  • COIN_RECEIVED (AccountService): fromUserId 제공 ✓
  • POST_PURCHASED_BY_COIN (AiImagePermissionService): userId 제공 ✓
  • POST_PURCHASED_BY_TICKET (AiImagePermissionService): userId 제공 ✓
  • POST_REVIEWED (PostReviewService): user.getId() 제공 ✓
  • LIKED (PostLikeService): user.getId() 제공 ✓
  • DERIVED_POST_CREATED (AiDerivedPostService): user.getId() 제공 ✓
  • FOLLOWED (FollowService): me.getId() 제공 ✓

NotificationPayload는 직렬화되어 저장되고, 조회 시 역직렬화되어 GetNotificationsResponse로 매핑됩니다. senderId는 응답에 항상 포함되므로, 프론트엔드에서 추가 처리가 필요 없습니다.

@yooooonshine yooooonshine merged commit eae7fe6 into develop Nov 23, 2025
2 checks passed
@yooooonshine yooooonshine changed the title [FEAT] : 알림 리팩토링 [REFACTOR] : 알림 리팩토링 Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

알림 리팩토링

1 participant