Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ dependencies {
implementation(Dependencies.SMTP)

implementation(Dependencies.GOOGLE_OAUTH)

implementation(Dependencies.LOG4J)
}

configurations.configureEach {
exclude(
group = Excludes.SPRING_BOOT_LOGGING_GROUP,
module = Excludes.SPRING_BOOT_LOGGING_MODULE
)
exclude(
group = Excludes.LOG4J_TO_SLF4J_GROUP,
module = Excludes.LOG4J_TO_SLF4J_MODULE
)
}

tasks.withType<KotlinCompile> {
Expand Down
18 changes: 4 additions & 14 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
object Dependencies {
// kotlin
const val KOTLIN_REFLECT = "org.jetbrains.kotlin:kotlin-reflect"
const val JACKSON = "com.fasterxml.jackson.module:jackson-module-kotlin:${DependencyVersions.JACKSON_VERSION}"
const val JACKSON_TYPE = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${DependencyVersions.JACKSON_VERSION}"

// web
const val SPRING_WEB = "org.springframework.boot:spring-boot-starter-web"

const val REDIS = "org.springframework.boot:spring-boot-starter-data-redis:${DependencyVersions.REDIS_VERSION}"

// database
const val SPRING_DATA_JPA = "org.springframework.boot:spring-boot-starter-data-jpa:${PluginVersions.SPRING_BOOT_VERSION}"
const val MYSQL_CONNECTOR = "mysql:mysql-connector-java:${DependencyVersions.MYSQL}"

const val SPRING_REDIS = "org.springframework.boot:spring-boot-starter-data-redis:${PluginVersions.SPRING_BOOT_VERSION}"

// security
const val SPRING_SECURITY = "org.springframework.boot:spring-boot-starter-security"

// test
const val SPRING_TEST = "org.springframework.boot:spring-boot-starter-test:${PluginVersions.SPRING_BOOT_VERSION}"

// open feign
const val OPEN_FEIGN = "org.springframework.cloud:spring-cloud-starter-openfeign:${DependencyVersions.OPEN_FEIGN_VERSION}"

// validation
const val SPRING_VALIDATION = "org.springframework.boot:spring-boot-starter-validation"

// json
const val JSON = "org.json:json:${DependencyVersions.JSON_VERSION}"

// Jwt
const val JWT = "io.jsonwebtoken:jjwt:${DependencyVersions.JWT_VERSION}"

// cloud
const val SPRING_CLOUD = "org.springframework.cloud:spring-cloud-dependencies:${DependencyVersions.SPRING_CLOUD_VERSION}"

const val SWAGGER = "org.springdoc:springdoc-openapi-ui:${DependencyVersions.SWAGGER_VERSION}"

// QueryDSL
const val QUERYDSL = "com.querydsl:querydsl-jpa:${DependencyVersions.QUERYDSL}"
const val QUERYDSL_PROCESSOR = "com.querydsl:querydsl-apt:${DependencyVersions.QUERYDSL}:jpa"

// apachePOI
const val APACHE_POI = "org.apache.poi:poi:${DependencyVersions.APACHE_POI}"
const val APACHE_POI_OOXML = "org.apache.poi:poi-ooxml:${DependencyVersions.APACHE_POI}"

Expand All @@ -59,7 +48,8 @@ object Dependencies {

const val GOOGLE_OAUTH = "com.google.auth:google-auth-library-oauth2-http:${DependencyVersions.GOOGLE_OAUTH2}"


//smtp
const val SMTP = "org.springframework.boot:spring-boot-starter-mail"

const val LOG4J = "org.springframework.boot:spring-boot-starter-log4j2"

}
7 changes: 7 additions & 0 deletions buildSrc/src/main/kotlin/Excludes.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object Excludes {
const val SPRING_BOOT_LOGGING_GROUP = "org.springframework.boot"
const val SPRING_BOOT_LOGGING_MODULE = "spring-boot-starter-logging"

const val LOG4J_TO_SLF4J_GROUP = "org.apache.logging.log4j"
const val LOG4J_TO_SLF4J_MODULE = "log4j-to-slf4j"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class ApplicationStatusProcessor(
) {
abstract fun process(applications: List<Application>, adminName: String, deviceTokens: List<String>)

protected fun sendNotification(title: String, message: String, deviceTokens: List<String>) {
protected fun sendNotification(title: String, message: String, deviceTokens: List<String?>) {
sendMessageUseCase.sendAll(deviceTokens, title, message)
}
}
20 changes: 19 additions & 1 deletion src/main/kotlin/dsm/pick2024/domain/fcm/service/FcmAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import dsm.pick2024.domain.fcm.domain.FcmMessage
import dsm.pick2024.domain.fcm.port.out.FcmSendPort
import dsm.pick2024.infrastructure.feign.fcm.FcmClient
import dsm.pick2024.infrastructure.googleoauth.port.out.GoogleOauthServicePort
import feign.FeignException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

@Service
class FcmAdapter(
private val fcmClient: FcmClient,
private val googleOauthServicePort: GoogleOauthServicePort
) : FcmSendPort {
val logger: Logger = LoggerFactory.getLogger("FcmAdapter")

override fun sendAll(deviceTokens: List<String?>, title: String, body: String) {
val token = googleOauthServicePort.getToken()
Expand All @@ -30,7 +34,21 @@ class FcmAdapter(
}

private fun sendMessage(fcmMessage: FcmMessage, token: String) {
fcmClient.sendMessage("Bearer " + token, fcmMessage)
try {
fcmClient.sendMessage("Bearer $token", fcmMessage)
} catch (e: FeignException) {
logger.error(
"⚠️Fcm failed 403 FeignException" +
"request: $fcmMessage" +
"error: ${e.message}"
)
} catch (e: Exception) {
logger.error(
"⚠️Fcm failed" +
"request: $fcmMessage" +
"error: ${e.message}"
)
}
}

private fun generateMessage(
Expand Down