Skip to content

Commit

Permalink
[FCM] FCM Account Key 주입 방식 변경(#84) (#85)
Browse files Browse the repository at this point in the history
* docs: 사진 프로필 필드, 타입 명세 수정(#84)

* feat: fcm account key 접근 방식 변경(#84)

- 기존에는 'classpath:~' 를 루트로 하는 경로를 이용해 fcm account key를 접근
- 배포시에 해당 경로를 인식하지 못해 리소스를 접근하지 못하는 에러 발생
- spring에서 제공하는 ClassPathResource를 이용하여 접근하는 방식으로 변경

* docs: 조회 기준 필드, 예시 명세 수정(#84)
  • Loading branch information
Minjae-An authored May 16, 2024
1 parent a123794 commit 8bbaade
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions be/src/main/java/yeonba/be/config/FcmConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;
import java.io.FileInputStream;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ClassPathResource;

@Configuration
public class FcmConfig {

@Value("${FCM_ACCOUNT_KEY_PATH}")
private Resource accountKey;
private String fcmAccountKeyPath;

@Bean
public FirebaseMessaging firebaseMessaging() throws IOException {

FileInputStream serviceAccount = new FileInputStream(accountKey.getFile());
ClassPathResource resource = new ClassPathResource(fcmAccountKeyPath);

FirebaseOptions firebaseOptions = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setCredentials(GoogleCredentials.fromStream(resource.getInputStream()))
.build();

return FirebaseMessaging.getInstance(FirebaseApp.initializeApp(firebaseOptions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class NotificationResponse {
private long senderId;

@Schema(
type = "number",
type = "string",
description = "알림 보낸 사용자 대표 프로필 사진 URL",
example = "profile-photo/1-0")
private String senderProfilePhotoUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class UserQueryRequest {
- 즐겨찾는 이성 : FAVORITES
- 나에게 관심 있는 이성(나에게 화살을 보낸 이성) : ARROW_SENDERS
- 나에게 화살을 보낸 이성 : ARROW_RECEIVERS""",
example = "RECOMMEND",
example = "FAVORITES",
in = ParameterIn.QUERY)
@NotBlank(message = "조회 기준은 반드시 입력되어야 합니다.")
@Pattern(
Expand Down

0 comments on commit 8bbaade

Please sign in to comment.