Skip to content

Refactor/#172 알림 엔티티 구조 개선 - 알림 관련 엔티티와 알림 설정 API 개선#173

Open
ojy0903 wants to merge 15 commits into
developfrom
refactor/#172
Open

Refactor/#172 알림 엔티티 구조 개선 - 알림 관련 엔티티와 알림 설정 API 개선#173
ojy0903 wants to merge 15 commits into
developfrom
refactor/#172

Conversation

@ojy0903

@ojy0903 ojy0903 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

📌 관련 이슈

🚀 개요

이번 PR에서 변경된 핵심 내용을 요약해주세요.

7월 9일 회의 내용에 따라 기존 예산 소진율을 반영하던 알림 엔티티에서 클릭수 관련 알림 수신 여부와 리포트 수신 여부로 엔티티 필드를 개선하고, 기존 알림 설정 API 를 엔티티 개선에 맞춰 수정합니다.
image

📄 작업 내용

구체적인 작업 내용을 설명해주세요.

  • OrgMemberNotificationSetting 내부 예산 필드 삭제 & 클릭수 급증, 봇 클릭, 리포트 알림으로 수정
  • OrgMemberNotificationSetting 필드 수정에 따른 로직 수정
  • OrgNotificationSetting 내부 클릭수 급증, 봇 클릭, 리포트 알림 필드 추가
  • OrgNotificationSetting 필드 추가에 따른 API 및 로직 수정 & 추가

📸 스크린샷 / 테스트 결과 (선택)

결과물 확인을 위한 사진이나 테스트 로그를 첨부해주세요.

크게 두가지 작업 내용으로 보면 될거 같습니다...!

  1. 7월 9일 회의 내용에 따라 기존에 OrgMemberNotificationSetting 내부 예산 관련 필드를 제거하고, 클릭수 급증, 봇 클릭, 리포트 알림 필드로 수정진행 & 관련 로직 수정 42a193a ~ 3913007

  2. OrgNotificationSetting 엔티티에서 조직 단위로 외부채널(슬랙, 디스코드) 에 알림을 보낼때도 어떤 알림을 보낼지 (클릭수 급증, 봇 클릭, 리포트 알림) 설정 및 구분이 필요하다고 판단되어 관련 필드를 추가했습니다.
    또한, 기존에 NotificationServiceImpl 내부 updateChannels 메서드에서 회원 개인의 브라우저 푸시, 이메일 푸시 여부와 ADMIN 이면 조직의 슬랙, 디스코드 웹훅 URL 까지 설정하던걸 별도의 API (PATCH /api/notification/settings/{orgId}/org) updateOrgSettings 메서드로 분리하여 updateOrgSettings 메서드에서 조직 외부 채널에 어떤 알림을 받을지 (클릭수 급증, 봇 클릭, 리포트 알림) 설정하는 것과 웹훅 URL 을 업데이트 하도록 수정했습니다.
    d62feea ~ fc3e4b6

웹훅 URL 입력 로직이 삭제된 (PATCH /api/notification/settings/{orgId}/channels) 동작 확인
image
image
image

새로 추가된 API
image

정상 응답 확인 및 DB 정상 저장 확인
image
image

알림 발송 테스트 정상 동작 확인
image
image
image



ERD 업데이트
image
image

+++
추가로 application.yml 의 ddl-auth : update 로는 필드 추가는 정상 반영하지만 필드 제거는 반영하지 않는 거 같아서, 머지 후 배포 DB 확인하여 SQL 로 수동 삭제 예정입니다.
image

✅ 체크리스트

  • 브랜치 전략(GitHub Flow)을 준수했나요?
  • 메서드 단위로 코드가 잘 쪼개져 있나요?
  • 테스트 통과 확인
  • 서버 실행 확인
  • API 동작 확인

🔍 리뷰 포인트 (Review Points)

리뷰어가 중점적으로 확인했으면 하는 부분을 적어주세요. (P1~P4 적용 가이드)

  • 다들 다른 일정도 있는걸로 알고있어서 천천히 리뷰 해주셔도 됩니다!!!
  • 7월 9일 회의 내용에 맞춰서 OrgMemberNotificationSetting 엔티티 수정하다가 생각해보니 OrgNotificationSetting 으로 외부 채널에 알림 보낼때도 어떤 알림을 수신하도록 설정되어있는지를 알아야 할거 같아서 추가해봤습니다... 괜찮을까요..??
  • OrgNotificationSetting 에 필드 추가를 진행하면서 기존에 외부 채널로 실제 알림을 보내는데 사용되는 NotificationServiceImpl.sendApiAlarmToOrg() 의 파라미터로 NotificationType 을 추가해봤습니다. 나중에 Kafka 등에서 알림 발송 메서드 호출 시 조직별로 슬랙, 디스코드 알림 전송 시에 해당 조직이 수신 여부를 어떻게 설정했는지 Kafka 는 알 필요 없게 하고 sendApiAlarmToOrg 서비스 로직에서 판별해서 수신 차단되어 있다면 자동으로 알림 스킵하도록 하는 의도로 해봤는데 어떤지 의견 남겨주세요...!!
  • 지금은 아래 사진과 같이 알림 수신 종류와 이메일, 브라우저 수신 여부가 각각 다른 API 에서 입력받고 있는데 이 둘을 하나로 합치는게 좋을까요...?
image image

💬 리뷰어 가이드 (P-Rules)
P1: 필수 반영 (Critical) - 버그 가능성, 컨벤션 위반. 해결 전 머지 불가.
P2: 적극 권장 (Recommended) - 더 나은 대안 제시. 가급적 반영 권장.
P3: 제안 (Suggestion) - 아이디어 공유. 반영 여부는 드라이버 자율.
P4: 단순 확인/칭찬 (Nit) - 사소한 오타, 칭찬 등 피드백.

Summary by CodeRabbit

  • 새로운 기능

    • 알림 설정에 급격한 클릭, 봇 클릭, 리포트 알림을 추가했습니다.
    • 조직 관리자가 Slack·Discord 연동과 외부 알림 유형을 별도로 설정할 수 있습니다.
    • 알림 유형별 외부 채널 수신 여부를 관리합니다.
  • 변경 사항

    • 개인 설정은 브라우저 푸시와 이메일 수신으로 단순화했습니다.
    • 기존 예산 기준 알림 설정을 새로운 알림 유형 기반 설정으로 변경했습니다.
    • 조직 알림 설정 변경 시 채널 및 웹훅 입력값을 검증합니다.

@ojy0903 ojy0903 self-assigned this Jul 10, 2026
@ojy0903 ojy0903 added ✨ Feature 새로운 기능 추가 🗄️ DB 데이터베이스, 엔티티, 마이그레이션 관련 ♻️ Refactor 코드 구조 개선 labels Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ojy0903, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57a0fbfa-7469-4850-8133-07913be290c7

📥 Commits

Reviewing files that changed from the base of the PR and between 25d7338 and 2624c31.

📒 Files selected for processing (2)
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/OrgMemberNotificationSetting.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/OrgNotificationSetting.java

Walkthrough

개인 알림 설정과 조직 외부 채널 설정을 분리하고, 봇 클릭·리포트·클릭 급증 알림 유형을 추가했습니다. 조직 설정 API와 유형별 Slack·Discord 전송 검사가 구현됐으며, 예산 알림 필드는 제거됐습니다.

Changes

알림 설정 및 전송 흐름

Layer / File(s) Summary
알림 설정 계약과 저장 모델
src/main/java/com/whereyouad/WhereYouAd/domains/notification/application/dto/..., src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/..., src/main/java/com/whereyouad/WhereYouAd/domains/notification/domain/constant/NotificationType.java
개인 채널은 브라우저 푸시·이메일로 축소되고, 알림 항목은 클릭 급증·봇 클릭·리포트로 변경됐습니다. 조직 설정과 응답 매핑에 외부 채널 알림 플래그가 추가됐습니다.
설정 업데이트 API와 서비스 로직
src/main/java/com/whereyouad/WhereYouAd/domains/notification/domain/service/..., src/main/java/com/whereyouad/WhereYouAd/domains/notification/presentation/...
조직 설정 PATCH 엔드포인트가 추가됐습니다. Slack·Discord 연결 해제, URL 검증, 활성화 충돌 검증과 조직 알림 설정 갱신이 구현됐으며 API 문서가 갱신됐습니다.
알림 유형별 외부 전송 제어
src/main/java/com/whereyouad/WhereYouAd/domains/notification/domain/service/NotificationServiceImpl.java
외부 알림 전송에 NotificationType을 전달하고, 조직 설정이 없거나 해당 유형이 비활성화된 경우 전송을 건너뛰도록 변경했습니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant NotificationController
  participant NotificationServiceImpl
  participant OrgNotificationSetting
  participant SlackDiscord
  Client->>NotificationController: 조직 설정 PATCH 요청
  NotificationController->>NotificationServiceImpl: updateOrgSettings(userId, orgId, request)
  NotificationServiceImpl->>OrgNotificationSetting: 채널 및 알림 유형 설정 갱신
  Client->>NotificationServiceImpl: sendApiAlarmToOrg(orgId, type, title, message)
  NotificationServiceImpl->>OrgNotificationSetting: 알림 유형 활성화 여부 확인
  NotificationServiceImpl->>SlackDiscord: 활성화된 알림 전송
Loading

Possibly related PRs

Suggested reviewers: jinnieusLab, kingmingyu

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 제목이 알림 엔티티 구조 개선과 알림 설정 API 개선이라는 핵심 변경을 정확히 요약합니다.
Description check ✅ Passed 템플릿의 관련 이슈, 개요, 작업 내용, 스크린샷/테스트, 체크리스트, 리뷰 포인트를 모두 갖추고 있습니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#172

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/whereyouad/WhereYouAd/domains/notification/presentation/docs/NotificationControllerDocs.java (1)

40-44: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

updateChannels의 400 응답 코드가 구현과 불일치합니다 — 정리가 필요합니다.

@Operation description은 "브라우저 푸시, 이메일"로 올바르게 업데이트했지만, @ApiResponses의 400 응답 코드(NOTIFICATION_400_2: URL 없이 알림 활성화, NOTIFICATION_400_3: 활성화+연결해제 동시 요청)는 여전히 남아있습니다. 이 URL 관련 에러들은 이제 updateOrgSettings(line 68)로 이동되었으며, updateChannels 서비스 구현에는 URL 검증이나 충돌 체크 로직이 없습니다. API 사용자가 잘못된 400 응답을 예상하게 됩니다.

📝 제안: updateChannels 400 응답 코드 제거
     `@Operation`(summary = "알림 채널 설정 변경", description = "회원 개인의 브라우저 푸시, 이메일 알림 채널을 설정합니다.")
     `@ApiResponses`({
             `@ApiResponse`(responseCode = "200", description = "변경 성공"),
-            `@ApiResponse`(responseCode = "400", description = "NOTIFICATION_400_2: URL 없이 알림 활성화\n\n NOTIFICATION_400_3 : 활성화+연결해제 동시 요청"),
             `@ApiResponse`(responseCode = "404", description = "해당 조직의 멤버가 아닙니다.")
     })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/whereyouad/WhereYouAd/domains/notification/presentation/docs/NotificationControllerDocs.java`
around lines 40 - 44, NotificationControllerDocs의 updateChannels 문서에 구현되지 않은 URL
검증 및 충돌 관련 400 응답 코드가 남아 있습니다. updateChannels의 `@ApiResponses에서`
NOTIFICATION_400_2와 NOTIFICATION_400_3 설명을 제거하고, 실제 서비스 구현과 일치하는 응답만 유지하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/OrgMemberNotificationSetting.java`:
- Around line 34-41: OrgMemberNotificationSetting의 alertRapidClicks,
alertBotClicks, alertReport 컬럼에 기존 데이터와의 호환을 위한 기본값을 추가하세요. 각 필드에
`@ColumnDefault`("false")를 적용하거나, 동등한 마이그레이션에서 해당 컬럼의 DB 기본값을 false로 명시하고 nullable
= false 설정은 유지하세요.

In
`@src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/OrgNotificationSetting.java`:
- Around line 41-48: OrgNotificationSetting의 alertRapidClicks, alertBotClicks,
alertReport 필드에 기존 isSlackEnabled 및 isDiscordEnabled와 동일하게
`@ColumnDefault`("false")를 추가하세요.

---

Outside diff comments:
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/notification/presentation/docs/NotificationControllerDocs.java`:
- Around line 40-44: NotificationControllerDocs의 updateChannels 문서에 구현되지 않은 URL
검증 및 충돌 관련 400 응답 코드가 남아 있습니다. updateChannels의 `@ApiResponses에서`
NOTIFICATION_400_2와 NOTIFICATION_400_3 설명을 제거하고, 실제 서비스 구현과 일치하는 응답만 유지하세요.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af23fb87-d794-4e53-a9fa-08d25f1631ba

📥 Commits

Reviewing files that changed from the base of the PR and between 7cda6e1 and 25d7338.

📒 Files selected for processing (10)
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/application/dto/request/NotificationRequest.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/application/dto/response/NotificationResponse.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/application/mapper/NotificationConverter.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/domain/constant/NotificationType.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/domain/service/NotificationService.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/domain/service/NotificationServiceImpl.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/OrgMemberNotificationSetting.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/persistence/entity/OrgNotificationSetting.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/presentation/NotificationController.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/notification/presentation/docs/NotificationControllerDocs.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗄️ DB 데이터베이스, 엔티티, 마이그레이션 관련 ✨ Feature 새로운 기능 추가 ♻️ Refactor 코드 구조 개선

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: 알림 엔티티 구조 개선 - 알림 관련 엔티티와 알림 설정 API 개선

1 participant