Skip to content

feat: 중복 저장 시 PIN_DUPLICATED 알림 발송 - #117

Open
sudosubin wants to merge 1 commit into
mainfrom
feat/fcm-pin-duplicated
Open

feat: 중복 저장 시 PIN_DUPLICATED 알림 발송#117
sudosubin wants to merge 1 commit into
mainfrom
feat/fcm-pin-duplicated

Conversation

@sudosubin

@sudosubin sudosubin commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

📌 Related Issue

  • 없음

🚀 Description

이미 저장돼 있던 장소를 다시 저장하면 이미 저장해둔 곳이에요 알림을 남깁니다. (PRD [SYS-002] Flow B)

방이 몇 개 중복이었든 장소당 한 건이고, 대상 이름에는 장소명만 싣습니다. 어느 방에서 중복이었는지는 알림함이 알리지 않습니다. (FR-021, EC-019) payload에는 { placeId }만 담아 앱이 장소 상세로 이동하도록 합니다.

중복 판정 기준으로 pins.source_id를 쓰려 했는데, ensureActiveInstagramSource가 게시물 URL 하나에 source 행 하나를 재사용해서 같은 글을 두 번 저장해도 sourceId가 같습니다. 그래서 task payload에 enqueuedAt을 싣고 그보다 먼저 만들어진 핀만 중복으로 봅니다.

이 기준이 필요한 이유는 재배달입니다. 큐는 최대 10회 재시도하고 워커는 핀을 저장한 뒤에도 던질 수 있어서, insert 결과의 차집합으로 판정하면 2회차에 앞선 시도가 넣은 핀이 전부 중복으로 잡힙니다. 재배달은 payload를 그대로 다시 받으므로 enqueuedAt이 같아 이 문제가 없습니다.

sequenceDiagram
    participant CT as Cloud Tasks
    participant W as PlaceWorkerController
    participant Repo as PlaceResultRepository
    participant Notif as NotificationService

    CT->>W: POST /tasks/pins (task)
    W->>Repo: save(task, matches)

    rect rgb(245, 245, 245)
        Note over Repo: 한 트랜잭션
        Repo->>Repo: places upsert
        Repo->>Repo: 기존 활성 핀 조회 (created_at < enqueuedAt)
        Note right of Repo: 핀 insert 전에 읽어야 함
        Repo->>Repo: pins insert (onConflictDoNothing)
    end

    Repo-->>W: duplicatedPlaces
    W->>Notif: PIN_DUPLICATED (장소당 1건)
    Note right of Notif: key에 enqueuedAt 포함, 재배달 시 접힘
Loading

📢 Notes

  • enqueuedAt은 optional입니다. 배포 시점에 큐에 남아 있던 옛 task는 판정 기준이 없어 중복을 알리지 않습니다.
  • key에 enqueuedAt을 넣어야 같은 글을 다시 저장했을 때 별개 행으로 남습니다. (TS-052)
  • 썸네일은 places.images ->> 0으로 읽는데, 현재 places.images를 채우는 코드가 없어서 항상 null입니다. images가 채워지면 코드 변경 없이 동작합니다.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: c211178b-6cf1-4961-883c-6afd4387c61f

📥 Commits

Reviewing files that changed from the base of the PR and between f46bce5 and 46b033f.

📒 Files selected for processing (11)
  • e2e/scenarios/place/place.e2e.spec.ts
  • e2e/scenarios/place/place.worker.scenarios.ts
  • src/common/tasks/pin-extraction-task.dto.ts
  • src/modules/notification/notification.repository.ts
  • src/modules/notification/notification.service.ts
  • src/modules/pin/pin.service.ts
  • src/modules/place/place-result.repository.ts
  • src/modules/place/place-worker.controller.spec.ts
  • src/modules/place/place-worker.controller.ts
  • src/modules/place/place.module.ts
  • src/modules/place/place.type.ts

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.

@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch 2 times, most recently from 5a4e3e5 to dc8bdc0 Compare August 30, 2026 15:30
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from 90eca1a to 96c25e6 Compare August 30, 2026 15:30
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from dc8bdc0 to d2e314e Compare August 30, 2026 15:42
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from 96c25e6 to cdcf3f5 Compare August 30, 2026 15:42
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from d2e314e to ce7a265 Compare August 30, 2026 15:46
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from cdcf3f5 to 0cffb31 Compare August 30, 2026 15:46
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from ce7a265 to 0fc589f Compare August 30, 2026 15:52
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch 2 times, most recently from e5a0c1b to ecfe648 Compare August 30, 2026 16:00
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from 0fc589f to 8993972 Compare August 30, 2026 16:00
@sudosubin sudosubin self-assigned this Aug 30, 2026
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from ecfe648 to 6d2b012 Compare August 30, 2026 16:14
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from 8993972 to 36a34b0 Compare August 30, 2026 16:14
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from 6d2b012 to d444bb7 Compare August 30, 2026 16:24
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch 2 times, most recently from cc841b2 to d66d70e Compare August 31, 2026 11:49
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from d444bb7 to 5d3a2b5 Compare August 31, 2026 11:49
@sudosubin
sudosubin marked this pull request as ready for review August 31, 2026 13:00
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from 5d3a2b5 to 283788b Compare August 31, 2026 13:28
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from d66d70e to 965caa0 Compare August 31, 2026 13:28
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from 283788b to 95cab62 Compare August 31, 2026 14:11
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch 2 times, most recently from e002b2f to c45047d Compare August 31, 2026 14:17
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch 2 times, most recently from 433a425 to a198393 Compare August 31, 2026 14:27
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from c45047d to 047dfc6 Compare August 31, 2026 14:27
@sudosubin
sudosubin force-pushed the feat/fcm-room-join-notifications branch from a198393 to 1df74e5 Compare August 31, 2026 15:28
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from 047dfc6 to 700d1ed Compare August 31, 2026 15:31
@sudosubin
sudosubin changed the base branch from feat/fcm-room-join-notifications to main August 31, 2026 15:31
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from 700d1ed to 19273a8 Compare September 1, 2026 01:24
@sudosubin
sudosubin changed the base branch from main to feat/fcm-push-payload September 1, 2026 01:25
@sudosubin
sudosubin force-pushed the feat/fcm-push-payload branch from b69eb6d to cd1b91d Compare September 1, 2026 01:31
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from 19273a8 to 0f94dde Compare September 1, 2026 01:31
이미 저장돼 있던 장소를 저장한 사람에게 알린다(PRD [SYS-002] Flow B).
방이 몇 개 중복이었든 장소당 한 건이고 대상 이름은 장소명만 싣는다(FR-021).

판정 기준은 task.enqueuedAt이다. sourceId로는 가를 수 없다 — 게시물 URL 하나에
source 행이 하나라 같은 글을 두 번 저장해도 sourceId가 같다. 큐가 최대 10회
재배달하는데, 재배달은 payload를 그대로 다시 받으므로 enqueuedAt이 같아 앞선
시도가 넣은 핀을 중복으로 잘못 잡지 않는다.
@sudosubin
sudosubin force-pushed the feat/fcm-pin-duplicated branch from 0f94dde to 46b033f Compare September 1, 2026 01:38
@sudosubin
sudosubin changed the base branch from feat/fcm-push-payload to main September 1, 2026 01:38
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