Skip to content

[Fix] 트래킹 중 푸시 알림이 늦게 나가는 현상 수정#123

Merged
pooreumjung merged 3 commits into
developfrom
fix/#121-fcm-data-only-notification
May 27, 2026
Merged

[Fix] 트래킹 중 푸시 알림이 늦게 나가는 현상 수정#123
pooreumjung merged 3 commits into
developfrom
fix/#121-fcm-data-only-notification

Conversation

@pooreumjung

@pooreumjung pooreumjung commented May 27, 2026

Copy link
Copy Markdown
Member

🧾 요약

  • 트래킹 알림이 앱 포그라운드 상태에서도 즉시 처리될 수 있도록 FCM 전송 방식을 조정
  • 트래킹 알림만 data-only로 발송하고, 일반 알림은 기존 notification payload 방식을 유지

🔗 이슈

✨ 변경 내용

  • 트래킹 알림 타입(TRACKING_PHOTO_MILESTONE, TRACKING_SUMMIT_REACHED)만 FCM data-only로 전송
  • 일반 알림은 기존처럼 notification + data payload 유지
  • data payload에 type, title, body, notificationId, distance 등 프론트 로컬 알림 처리용 필드 포함
  • extras JSON 중복 필드 제거 후 flat data 구조로 통일
  • data-only 정책을 NotificationType 내부 속성으로 이동
  • FCM dispatcher 테스트 추가

✅ 확인

  • 빌드 OK
  • 테스트 OK

Summary by CodeRabbit

Release Notes

  • New Features

    • Notification delivery now supports multiple dispatch modes based on notification type.
  • Bug Fixes

    • Tracking-related notifications (photo milestones, summit reached) now use optimized delivery format.
    • Community notifications continue to use standard delivery.
  • Tests

    • Added comprehensive test coverage for notification dispatcher behavior.

Review Change Stack

@pooreumjung pooreumjung self-assigned this May 27, 2026
@pooreumjung pooreumjung added the bug Something isn't working label May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

FCM notification payload construction is refactored to conditionally exclude the Notification part for tracking alerts while keeping it for general notifications. NotificationType enum gains a dataOnly flag, FcmService uses it to conditionally build the Notification, and AsyncNotificationDispatcher wires the flag through while simplifying extras handling.

Changes

Data-Only Notification Payloads for Tracking Alerts

Layer / File(s) Summary
NotificationType dataOnly contract
src/main/java/com/semosan/api/domain/notification/enums/NotificationType.java
NotificationType enum adds dataOnly boolean field to constructor. Tracking types (TRACKING_PHOTO_MILESTONE, TRACKING_SUMMIT_REACHED) are marked dataOnly=true; general types (COMMUNITY_COMMENT) are dataOnly=false. New public method isDataOnly() exposes the flag.
FcmService conditional Notification payload
src/main/java/com/semosan/api/common/fcm/FcmService.java
FcmService.sendMessage signature adds boolean dataOnly parameter. Notification part (title and body) is conditionally added to the FCM message only when dataOnly is false; data payload is always included when non-empty.
AsyncNotificationDispatcher wiring and payload flattening
src/main/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcher.java
Dispatcher calls fcmService.sendMessage with cmd.type().isDataOnly() flag. Jackson ObjectMapper is removed. buildDataPayload flattens non-null cmd.extras entries directly into the data map rather than JSON-serializing them, while preserving type, title, body, and notificationId fields.
AsyncNotificationDispatcher payload tests
src/test/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcherTest.java
Test class verifies payload construction for tracking (TRACKING_PHOTO_MILESTONE) and general (COMMUNITY_COMMENT) notifications. Tracking test asserts dataOnly flag is true and payload includes distance and notificationId without extras. General notification test asserts dataOnly flag is false and payload includes type, title, and body without extras.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • SEMOSAN/SEMOSAN_BE#110: Adds NotificationType.TRACKING_SUMMIT_REACHED, which this PR marks as dataOnly=true and incorporates into the data-only FCM payload strategy.
  • SEMOSAN/SEMOSAN_BE#117: Modifies the same TRACKING_PHOTO_MILESTONE and TRACKING_SUMMIT_REACHED titleTemplate strings; this PR adds the dataOnly flag to those same enum constants.

Suggested labels

enhancement

Poem

🐰 A rabbit hops through payloads bright,
Tracking notes now shine data-right,
Jackson gone, extras flattened clean,
Firebase rings with flags pristine,
From Seoul peaks to milestone dreams.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #121 objectives: tracking notifications are sent data-only, general notifications retain notification+data payloads, data includes required fields (title, body, type, distance, notificationId), and payload strategy is separated by notification type.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing data-only notification handling for tracking types: FcmService parameter updates, NotificationType enum modifications, AsyncNotificationDispatcher payload flattening, and corresponding test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title '[Fix] 트래킹 중 푸시 알림이 늦게 나가는 현상 수정' describes fixing delayed tracking push notifications, which directly aligns with the main objective of the PR: adjusting FCM strategy for tracking notifications to be processed immediately while the app is foregrounded.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/#121-fcm-data-only-notification

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

@pooreumjung pooreumjung changed the title Fix/#121 fcm data only notification [Fix] 트래킹 중 푸시 알림이 늦게 나가는 현상 수정 May 27, 2026

@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.

🧹 Nitpick comments (1)
src/test/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcherTest.java (1)

61-97: ⚡ Quick win

Add a dedicated TRACKING_SUMMIT_REACHED case.

The data-only behavior now lives on each enum constant, but this suite only pins TRACKING_PHOTO_MILESTONE. A mistaken flag on TRACKING_SUMMIT_REACHED would regress that notification path without failing here.

🤖 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/test/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcherTest.java`
around lines 61 - 97, The test dispatchKeepsGeneralNotificationPayload currently
only verifies data-only behavior for TRACKING_PHOTO_MILESTONE; add a dedicated
assertion/test for NotificationType.TRACKING_SUMMIT_REACHED to prevent
regressions if its data-only flag changes. Update
AsyncNotificationDispatcherTest by either adding a new test method (or an
additional block in dispatchKeepsGeneralNotificationPayload) that constructs a
NotificationDispatchCommand with NotificationType.TRACKING_SUMMIT_REACHED (same
title/body/data shape and token) and verifies via the fcmService ArgumentCaptor
that the sent data contains the expected common entries ("type", "title",
"body") and doesNotContainKey("extras") (or the exact expected behavior for that
enum). Ensure you reference AsyncNotificationDispatcher.dispatch and
NotificationDispatchCommand when adding the new assertion so the test covers
TRACKING_SUMMIT_REACHED explicitly.
🤖 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.

Nitpick comments:
In
`@src/test/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcherTest.java`:
- Around line 61-97: The test dispatchKeepsGeneralNotificationPayload currently
only verifies data-only behavior for TRACKING_PHOTO_MILESTONE; add a dedicated
assertion/test for NotificationType.TRACKING_SUMMIT_REACHED to prevent
regressions if its data-only flag changes. Update
AsyncNotificationDispatcherTest by either adding a new test method (or an
additional block in dispatchKeepsGeneralNotificationPayload) that constructs a
NotificationDispatchCommand with NotificationType.TRACKING_SUMMIT_REACHED (same
title/body/data shape and token) and verifies via the fcmService ArgumentCaptor
that the sent data contains the expected common entries ("type", "title",
"body") and doesNotContainKey("extras") (or the exact expected behavior for that
enum). Ensure you reference AsyncNotificationDispatcher.dispatch and
NotificationDispatchCommand when adding the new assertion so the test covers
TRACKING_SUMMIT_REACHED explicitly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 61d961fc-dc04-41a9-9649-80c6851520c0

📥 Commits

Reviewing files that changed from the base of the PR and between 84c6974 and 7ee5071.

📒 Files selected for processing (4)
  • src/main/java/com/semosan/api/common/fcm/FcmService.java
  • src/main/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcher.java
  • src/main/java/com/semosan/api/domain/notification/enums/NotificationType.java
  • src/test/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcherTest.java

@pooreumjung
pooreumjung merged commit 1a1734d into develop May 27, 2026
3 checks passed
@howooyeon
howooyeon deleted the fix/#121-fcm-data-only-notification branch May 29, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] 트래킹 중 푸시 알림이 늦게 가거나 누락되는 현상

1 participant