-
Notifications
You must be signed in to change notification settings - Fork 3
[feature] React Native 알림 기능 구현 API #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lepitaaar
merged 54 commits into
develop/be
from
feature/#776-add-fcm-push-noti-alert-MOA-279
Nov 6, 2025
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
73ec7d8
feature: add fcm token save function
lepitaaar d3458b4
feature: fcm 토큰이 존재할 시 timestamp 업데이트 기능 추가
lepitaaar 6e20c57
feature: add 구독중인 clubIds 목록 필드 추가
lepitaaar 2cf911c
feature: add 구독중인 clubIds 업데이트 메서드
lepitaaar 8e96f3e
feature: Optinal 타입 변경
lepitaaar a63af93
feature: 토큰 Not Found 에러 추가
lepitaaar ac5807e
feature: subscribe Post, Get 메서드 추가
lepitaaar 68193a4
refactor: 메서드 이름 구분 및 request param으로 token 을 받음
lepitaaar bea0088
chore: add gitignore firebase.json
lepitaaar 0a335a0
chore: add firebase sdk dependency
lepitaaar 8a26c4a
feature: add fcm initializer
lepitaaar 1d7fcc5
refactor: fcm 초기화가 되지않을시 어플리케이션 실행 안되게 변경
lepitaaar 2bb510b
refactor: 잘못된 스케쥴링 시간 주석 변경
lepitaaar 16ece0a
feature: 동아리 fcm topic 구독 추가
lepitaaar e31414e
feature: 동아리 모집 상태 변경시 알림 전송
lepitaaar 110cce5
fix: classpath로 빌드 후 resource 파일 가져올 수 있게 수정
lepitaaar e5fc874
feature: 동아리 지원상태가 변경될때 이전상태와 다를경우 알람 전송
lepitaaar 1b14ff6
feature: 구독 요청의 clubIds 목록이 존재하는 동아리인지 검증
lepitaaar 1209811
feature: firebase 구독요청 비동기
lepitaaar d95a64d
feature: 동아리 검증 로직을 Set으로 변경하여 시간복잡도를 O(N+M)으로 줄임
lepitaaar 86083c3
refactor: List 로 자료형 변경
lepitaaar fcf21e1
refactor: List 로 자료형 변경
lepitaaar 446263d
feature: 블로킹 로직을 Async로 이동
lepitaaar 537e21a
refactor: 테스용 print to log로 변경
lepitaaar 62db43f
feature: 재시도 기능 추가
lepitaaar c47d023
chore: retry 의존성 추가
lepitaaar ad79e11
refactor: swagger api 설명 추가
lepitaaar 89638c7
feature: test코드 작성
lepitaaar 261d7ad
refactor: 넓은 범위 Exception handle 축소
lepitaaar 9404757
refactor: 중복 코드 삭제
lepitaaar 56050fc
refactor: Timeout 추가
lepitaaar 2e92dbf
refactor: not registered 토큰 제거 로직 변경
lepitaaar 740327a
refactor: 네트워킹 작업과 디비 트랜잭션 서비스 분리
lepitaaar 049ad63
refactor: 비동기 메서드 응답을 CompletableFuture<Void>로 변경하여 호출 로직에서 에러 로깅하게 변경
lepitaaar fc582fb
feature: firebaseMessage 인스턴스 빈 주입
lepitaaar 77d0a30
refactor: UnRegistered 토큰 구독 시 발생하는 오류 Mockito로 성공처리
lepitaaar 1ce0fde
refactor: dirty 체킹안되는 코드 변경
lepitaaar dd81a4b
refactor: cors 추가
lepitaaar 613db2a
refactor: POST to PUT 으로 메서드 변경
lepitaaar ac4c3b3
refactor: async thread pool 크기 제한
lepitaaar 8b60afc
refactor: logging message 변경
lepitaaar 011d418
chore: pr test에 firebase.json 삽입 추가
lepitaaar 0ac6739
test: pr test 용 로깅 try catch
lepitaaar b32b1cc
chore: secret 값 base64 디코딩으로 읽기
lepitaaar 539f874
fix: 테스트 실패 오류 수정
lepitaaar 63813ea
refactor: option stream close 추가 및 초기화 실패시 오류 발생
lepitaaar 12712e6
refactor: 반환 값 null 대신 CompletableFuture.completedFuture(null) 변경
lepitaaar 6180ca0
refactor: 토큰이 존재할 때만 삭제 로그 작성
lepitaaar 5f687e3
test: 등록되지않은 토큰을 삭제한다 테스트 추가
lepitaaar f5d8a62
fix: 엔티티클래스 private 접근자 추가
lepitaaar aaf068e
fix: 조건문 조건 오류 수정
lepitaaar 0e15534
refactor: 알림전송 책임 분리
lepitaaar 245b438
fix: Mockito로 생성된 club 엔티티의 id를 가져올 수 있게 변경
lepitaaar 3284cc8
refactor: FCM 구독중 예외 발생시 예외를 throw 하지않고 로깅만함
lepitaaar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,3 +39,4 @@ out/ | |
|
|
||
| application.properties | ||
| moadong.json | ||
| firebase.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
backend/src/main/java/moadong/fcm/controller/FcmController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package moadong.fcm.controller; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AllArgsConstructor; | ||
| import moadong.fcm.payload.request.ClubSubscribeRequest; | ||
| import moadong.fcm.payload.request.FcmSaveRequest; | ||
| import moadong.fcm.service.FcmService; | ||
| import moadong.global.payload.Response; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/fcm") | ||
| @AllArgsConstructor | ||
| @Tag(name = "FCM", description = "FCM 토큰 관리 및 알림 전송 기능 API") | ||
| public class FcmController { | ||
| private final FcmService fcmService; | ||
|
|
||
| @Operation(summary = "FCM 토큰 저장", description = "FCM 토큰을 서버에 저장합니다.") | ||
| @PostMapping | ||
| public ResponseEntity<?> saveFcmToken(@RequestBody @Validated FcmSaveRequest request) { | ||
| fcmService.saveFcmToken(request.fcmToken()); | ||
| return Response.ok("success save fcm token"); | ||
| } | ||
|
|
||
| @Operation(summary = "동아리 모집정보 알림 구독", description = "특정 동아리들의 모집 정보가 변경되면저거 하면 알림을 받도록 구독합니다.") | ||
| @PutMapping("/subscribe") | ||
| public ResponseEntity<?> subscribeRecruitment(@RequestBody @Validated ClubSubscribeRequest request) { | ||
| fcmService.subscribeClubs(request.fcmToken(), request.clubIds()); | ||
| return Response.ok("success subscribe club"); | ||
| } | ||
|
|
||
| @Operation(summary = "구독한 동아리 목록 조회", description = "FCM 토큰을 기준으로 구독중인 동아리 목록을 조회합니다.") | ||
| @GetMapping("/subscribe") | ||
| public ResponseEntity<?> getSubscribedClubs(@RequestParam("fcmToken") | ||
| @Validated @NotNull String fcmToken) { | ||
| return Response.ok(fcmService.getSubscribeClubs(fcmToken)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package moadong.fcm.entity; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
lepitaaar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import lombok.NoArgsConstructor; | ||
| import org.springframework.data.annotation.Id; | ||
| import org.springframework.data.mongodb.core.mapping.Document; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Document("fcm_tokens") | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| @Getter | ||
| @Builder | ||
| public class FcmToken { | ||
|
|
||
| @Id | ||
| private String id; | ||
|
|
||
| private String token; | ||
|
|
||
| @Builder.Default | ||
| private List<String> clubIds = new ArrayList<>(); | ||
|
|
||
| @Builder.Default | ||
| private LocalDateTime timestamp = LocalDateTime.now(); | ||
|
|
||
| public void updateTimestamp() { | ||
| this.timestamp = LocalDateTime.now(); | ||
| } | ||
|
|
||
| public void updateClubIds(List<String> clubIds) { | ||
| this.clubIds.clear(); | ||
| this.clubIds.addAll(clubIds); | ||
| } | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/moadong/fcm/payload/request/ClubSubscribeRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package moadong.fcm.payload.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public record ClubSubscribeRequest( | ||
| @NotNull | ||
| String fcmToken, | ||
| @NotNull | ||
| ArrayList<String> clubIds | ||
| ) { | ||
| } |
9 changes: 9 additions & 0 deletions
9
backend/src/main/java/moadong/fcm/payload/request/FcmSaveRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package moadong.fcm.payload.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record FcmSaveRequest( | ||
| @NotNull | ||
| String fcmToken | ||
| ) { | ||
| } |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/moadong/fcm/payload/response/ClubSubscribeListResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package moadong.fcm.payload.response; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record ClubSubscribeListResponse( | ||
| List<String> clubIds | ||
| ) { | ||
| } |
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/moadong/fcm/repository/FcmTokenRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package moadong.fcm.repository; | ||
|
|
||
| import moadong.fcm.entity.FcmToken; | ||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface FcmTokenRepository extends MongoRepository<FcmToken, String> { | ||
| Optional<FcmToken> findFcmTokenByToken(String fcmToken); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.