From 42d1c43ed5c5657f510139c8a73ed4c1b07aef6a Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Mon, 16 Sep 2024 18:37:41 +0900 Subject: [PATCH 1/6] =?UTF-8?q?update=20::=20firebase=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index 8e45a76..fdcd349 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { implementation("io.github.openfeign:feign-core:11.8") implementation("io.github.openfeign:feign-jackson:11.8") implementation("org.springframework.boot:spring-boot-starter-data-redis") + implementation("com.google.firebase:firebase-admin:9.1.1") } dependencyManagement { From 97da14d91eaa416dc1286c163cb7f74833dd391b Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Mon, 16 Sep 2024 18:39:01 +0900 Subject: [PATCH 2/6] update :: update yml --- src/main/resources/application.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 58b30e9..ea10726 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -27,4 +27,20 @@ dataporter: key: ${DATAPORTER_KEY} openweather: - key: ${OPENWATER_KEY} \ No newline at end of file + key: ${OPENWATER_KEY} + +fcm: + url: ${FCM_URL} + +cloud: + aws: + region: + static: ${AWS_REGION} + credentials: + access-key: ${AWS_ACCESS} + secret-key: ${AWS_SECRET} + s3: + bucket: ${AWS_BUCKET_NAME} + url: ${AWS_URL} + stack: + auto: false \ No newline at end of file From 49093bfe0a2808656fbe6fecb3fcecfc1467b2b9 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Mon, 16 Sep 2024 18:39:18 +0900 Subject: [PATCH 3/6] create :: FcmProperties --- .../ondosee/global/config/properties/FcmProperties.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/kotlin/com/ondosee/global/config/properties/FcmProperties.kt diff --git a/src/main/kotlin/com/ondosee/global/config/properties/FcmProperties.kt b/src/main/kotlin/com/ondosee/global/config/properties/FcmProperties.kt new file mode 100644 index 0000000..bee91e0 --- /dev/null +++ b/src/main/kotlin/com/ondosee/global/config/properties/FcmProperties.kt @@ -0,0 +1,10 @@ +package com.ondosee.global.config.properties + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.boot.context.properties.ConstructorBinding + +@ConfigurationProperties(prefix = "fcm") +@ConstructorBinding +class FcmProperties( + val url: String +) From d29ed760a1e2fe2dabb6b9af606a2638341ba84f Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Mon, 16 Sep 2024 18:39:28 +0900 Subject: [PATCH 4/6] create :: FcmConfig --- .../com/ondosee/global/config/FcmConfig.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/kotlin/com/ondosee/global/config/FcmConfig.kt diff --git a/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt b/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt new file mode 100644 index 0000000..0a25eb5 --- /dev/null +++ b/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt @@ -0,0 +1,40 @@ +package com.ondosee.global.config + +import com.google.auth.oauth2.GoogleCredentials +import com.google.firebase.FirebaseApp +import com.google.firebase.FirebaseOptions +import com.ondosee.global.config.properties.FcmProperties +import org.springframework.context.annotation.Configuration +import java.io.File +import java.net.URL +import java.nio.file.Files +import java.nio.file.Paths +import javax.annotation.PostConstruct + +@Configuration +class FcmConfig( + private val fcmProperties: FcmProperties +) { + companion object { + const val PATH = "./credentials.json" + } + + @PostConstruct + fun init() { + runCatching { + URL(fcmProperties.url).openStream().use { + Files.copy(it, Paths.get(PATH)) + val file = File(PATH) + if (FirebaseApp.getApps().isEmpty()) { + val options = FirebaseOptions.builder() + .setCredentials(GoogleCredentials.fromStream(file.inputStream())) + .build() + FirebaseApp.initializeApp(options) + } + file.delete() + } + }.onFailure { + it.printStackTrace() + } + } +} \ No newline at end of file From c3df07ff55d6c98abdfca9bdabedb07d4bf82cfd Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Wed, 18 Sep 2024 20:22:34 +0900 Subject: [PATCH 5/6] =?UTF-8?q?update=20::=20FcmConfig=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EA=B3=BC=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/ondosee/global/config/FcmConfig.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt b/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt index 0a25eb5..c19a9be 100644 --- a/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt +++ b/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt @@ -26,10 +26,10 @@ class FcmConfig( Files.copy(it, Paths.get(PATH)) val file = File(PATH) if (FirebaseApp.getApps().isEmpty()) { - val options = FirebaseOptions.builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(file.inputStream())) .build() - FirebaseApp.initializeApp(options) + .run(FirebaseApp::initializeApp) } file.delete() } From 8ee4966ba1e582c8a19f7eed0ca77e38b4bbdcf5 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Wed, 18 Sep 2024 21:15:30 +0900 Subject: [PATCH 6/6] =?UTF-8?q?update=20::=20FcmConfig=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EA=B3=BC=EC=A0=95=20=EC=88=98=EC=A0=9522?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ondosee/global/config/FcmConfig.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt b/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt index c19a9be..6028c3f 100644 --- a/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt +++ b/src/main/kotlin/com/ondosee/global/config/FcmConfig.kt @@ -24,15 +24,15 @@ class FcmConfig( runCatching { URL(fcmProperties.url).openStream().use { Files.copy(it, Paths.get(PATH)) - val file = File(PATH) - if (FirebaseApp.getApps().isEmpty()) { - FirebaseOptions.builder() - .setCredentials(GoogleCredentials.fromStream(file.inputStream())) - .build() - .run(FirebaseApp::initializeApp) - } - file.delete() } + val file = File(PATH) + if (FirebaseApp.getApps().isEmpty()) { + FirebaseOptions.builder() + .setCredentials(GoogleCredentials.fromStream(file.inputStream())) + .build() + .run(FirebaseApp::initializeApp) + } + file.delete() }.onFailure { it.printStackTrace() }