Skip to content

Commit 5b86755

Browse files
committed
✨ feat: FCM 토큰 알림 테스트할 API 구현 (임시)
1 parent 1d66bf5 commit 5b86755

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.example.scoi.domain;
2+
3+
import com.example.scoi.domain.websocket.enums.RiseOrFall;
4+
import com.example.scoi.global.util.FcmUtil;
5+
import com.google.firebase.messaging.FirebaseMessagingException;
6+
import lombok.RequiredArgsConstructor;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
@RestController
12+
@RequiredArgsConstructor
13+
@Slf4j
14+
public class TestController {
15+
16+
private final FcmUtil fcmUtil;
17+
18+
@GetMapping("/test")
19+
public String test(){
20+
21+
// 테스트
22+
String code = "USDT";
23+
String current = "10000";
24+
String percent = "10";
25+
RiseOrFall riseOrFall = RiseOrFall.RISE;
26+
27+
// 전체 사용자에게 알림 보내기
28+
try {
29+
fcmUtil.sendNotificationForDepegging(
30+
code+" 가격 변동 알림",
31+
"평소보다 "+code+" 가격이 "+current+"원으로 약 "+percent+"% "+riseOrFall.name()
32+
);
33+
} catch (FirebaseMessagingException e){
34+
log.error("[ FcmUtil ]: 알림 전송 실패, 에러 코드: {}, 스택 트레이스: {}", e.getMessagingErrorCode(), e.getStackTrace());
35+
}
36+
37+
return "test";
38+
}
39+
}

src/main/java/com/example/scoi/global/config/SecurityConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class SecurityConfig {
3737
"/auth/login", // 로그인
3838
"/auth/reissue", // 토큰 재발급
3939
"/auth/password/reset", // 비인증 비밀번호 재설정
40+
"/test", // 임시
4041
"/swagger-ui/**",
4142
"/v3/api-docs/**",
4243
"/swagger-resources/**",

0 commit comments

Comments
 (0)