Skip to content

Comments

[feature] 개발서버에서 동아리 모집 상태 변경시 라이브서버 푸시알림 전송안되게 변경한다#1079

Merged
lepitaaar merged 4 commits intodevelop/befrom
feature/#1078-seperate-fcm-token-staging-live-MOA-540
Jan 20, 2026
Merged

[feature] 개발서버에서 동아리 모집 상태 변경시 라이브서버 푸시알림 전송안되게 변경한다#1079
lepitaaar merged 4 commits intodevelop/befrom
feature/#1078-seperate-fcm-token-staging-live-MOA-540

Conversation

@lepitaaar
Copy link
Contributor

@lepitaaar lepitaaar commented Jan 20, 2026

#️⃣연관된 이슈

#1078

📝작업 내용

로컬, 스테이징, 프로덕션으로 나눠 fcm 메시지 전송에 영향이 가지않게 변경
fcm 전송시 로깅 추가

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

Summary by CodeRabbit

릴리스 노트

  • 개선사항

    • 푸시 전송 로깅 강화로 전송 시작·성공(메시지 ID)·실패 원인 확인 가능
    • 환경(prod/기타)에 따른 푸시 주제(topic) 해석 적용
    • 모집 상태가 실제로 변경될 때만 알림 발송해 불필요한 알림 감소
  • 테스트

    • 모집 상태 관련 테스트를 정적 대신 인스턴스 기반 목킹으로 전환하여 검증 신뢰도 향상

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

- FcmTopicResolver 생성하여 spring.profiles.active 기반 토픽 prefix 생성
- RecruitmentStateCalculator를 @component로 리팩터링하여 FcmTopicResolver 주입
- FcmAsyncService 구독/구독해제 시 prefixed 토픽 사용하도록 수정
- application.properties에 기본 profile을 local로 설정

토픽 네이밍:
- prod: clubId (기존 호환성 유지)
- staging: staging_clubId
- local: local_clubId
@lepitaaar lepitaaar self-assigned this Jan 20, 2026
@lepitaaar lepitaaar added ✨ Feature 기능 개발 💾 BE Backend labels Jan 20, 2026
@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
moadong Ready Ready Preview, Comment Jan 20, 2026 4:32am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • 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

Walkthrough

RecruitmentStateCalculator를 정적 유틸에서 Spring 컴포넌트로 전환하고 FcmTopicResolver를 도입해 FCM 토픽에 프로파일 접두사를 적용했습니다. 관련 호출 지점(ClubProfileService, RecruitmentStateChecker, FcmAsyncService, Club 등)을 인스턴스 의존성으로 변경하고 푸시 전송 로깅·중복 전송 방지 로직과 테스트를 수정했습니다.

Changes

코호트 / 파일(s) 요약
RecruitmentStateCalculator DI 변환
backend/src/main/java/moadong/club/util/RecruitmentStateCalculator.java
@Component, @RequiredArgsConstructor 추가, static → 인스턴스 메서드(calculate, buildRecruitmentMessage)로 전환, 기존/신규 상태 동일 시 조기 반환 추가, FcmTopicResolver 주입 사용.
호출자 변경 (의존성 주입)
backend/src/main/java/moadong/club/service/ClubProfileService.java, backend/src/main/java/moadong/club/service/RecruitmentStateChecker.java
RecruitmentStateCalculator 필드 추가 및 기존 static 호출을 인스턴스 호출로 변경(생성자 인수 변경).
FCM 토픽 해석 및 구독/구독해제
backend/src/main/java/moadong/fcm/util/FcmTopicResolver.java, backend/src/main/java/moadong/fcm/service/FcmAsyncService.java
새로운 FcmTopicResolver 컴포넌트 추가(프로파일 기반 접두사), subscribe/unsubscribe 및 전송에서 resolveTopic(clubId) 사용.
로깅/전송 변경
backend/src/main/java/moadong/club/entity/Club.java
FirebaseMessaging.send 결과의 messageId를 변수로 캡처해 성공 로그에 포함; 실패 로그에 clubId 포함 등 전후 로그 개선.
테스트 수정
backend/src/test/java/moadong/club/service/ClubProfileServiceDateTest.java, backend/src/test/java/moadong/club/service/RecruitmentStateCheckerTest.java
RecruitmentStateCalculator 정적 모킹에서 인스턴스 @Mock 모킹으로 전환, 테스트 검증을 calculator.calculate 호출 중심으로 변경.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler
    participant RecruitmentStateChecker
    participant RecruitmentStateCalculator
    participant FcmAsyncService
    participant Firebase

    Scheduler->>RecruitmentStateChecker: 주기적 검사 트리거
    RecruitmentStateChecker->>RecruitmentStateCalculator: calculate(club, start, end)
    RecruitmentStateCalculator->>RecruitmentStateCalculator: oldStatus vs newStatus 비교
    alt 상태 변경
        RecruitmentStateCalculator->>FcmAsyncService: build message & send(topic=resolveTopic(clubId))
        FcmAsyncService->>Firebase: sendMessage / subscribe / unsubscribe
        Firebase-->>FcmAsyncService: messageId / 결과
        FcmAsyncService-->>RecruitmentStateCalculator: 전송 결과 전달
    else 상태 동일
        RecruitmentStateCalculator-->>RecruitmentStateChecker: no-op
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • PororoAndFriends
  • Zepelown
  • alsdddk
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 개발서버에서 동아리 모집 상태 변경 시 라이브서버 푸시알림 전송을 방지하는 기능 추가에 관한 명확한 변경사항을 나타낸다.
Linked Issues check ✅ Passed PR의 코드 변경사항이 MOA-540 이슈의 요구사항을 충족한다. FcmTopicResolver를 추가하여 환경별 FCM 토픽에 prefix를 추가하고, RecruitmentStateCalculator를 DI 컴포넌트로 변환하여 환경별 토픽 구독/전송을 분리했다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 MOA-540에서 요구한 FCM 토픽 환경별 분리 구현 범위 내에 있다. 로깅 추가 및 테스트 업데이트는 해당 구현을 지원하는 범위 내 변경이다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

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

@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Test Results

75 tests   70 ✅  18s ⏱️
14 suites   3 💤
14 files     2 ❌

For more details on these failures, see this check.

Results for commit 773bada.

♻️ This comment has been updated with latest results.

Copy link
Member

@Zepelown Zepelown left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In `@backend/src/main/java/moadong/fcm/util/FcmTopicResolver.java`:
- Around line 9-16: The resolveTopic method in FcmTopicResolver uses the raw
activeProfile value which may contain comma-separated profiles; change
resolveTopic to parse activeProfile (split on ',' and trim) then decide: if the
parsed list contains "prod" or its first non-empty profile equals "prod" return
clubId, otherwise prefix the selected profile (first non-empty profile) to
clubId; update references to activeProfile in resolveTopic to use the
parsed/normalized profile value to avoid producing names like
"prod,aws_{clubId}".
🧹 Nitpick comments (1)
backend/src/main/java/moadong/club/entity/Club.java (1)

147-155: 로깅 추가는 PR 목표에 부합합니다.

FCM 알림 전송의 시작, 성공, 실패 상태를 추적할 수 있는 로깅이 잘 추가되었습니다. messageId를 캡처하여 로깅하는 것은 디버깅 및 알림 추적에 유용합니다.

선택적 개선 사항: 현재 예외가 로그만 남기고 조용히 무시되고 있어서 호출자가 알림 전송 성공 여부를 알 수 없습니다. 필요시 성공/실패를 반환하는 것을 고려해 볼 수 있습니다.

선택적 개선: 성공 여부 반환
-    public void sendPushNotification(Message message) {
+    public boolean sendPushNotification(Message message) {
         try {
             log.info("FCM 알림 전송 시작 - clubId: {}, clubName: {}", this.id, this.name);
             String messageId = FirebaseMessaging.getInstance().send(message);
             log.info("FCM 알림 전송 성공 - clubId: {}, messageId: {}", this.id, messageId);
+            return true;
         } catch (FirebaseMessagingException e) {
             log.error("FCM 알림 전송 실패 - clubId: {}, error: {}", this.id, e.getMessage());
+            return false;
         }
     }

@lepitaaar lepitaaar merged commit 7bb7517 into develop/be Jan 20, 2026
2 of 5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 20, 2026
@lepitaaar lepitaaar deleted the feature/#1078-seperate-fcm-token-staging-live-MOA-540 branch January 22, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💾 BE Backend ✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants