From b0184159ebf92ea71538d12f06e0b17e6d4d2789 Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Fri, 30 Dec 2022 11:35:16 +0900 Subject: [PATCH] add: (#261) SendPushMessagePort --- .../notification/spi/SendPushMessagePort.kt | 19 +++++++++++++++++++ .../thirdparty/notification/FcmAdapter.kt | 7 ++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/notification/spi/SendPushMessagePort.kt diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/notification/spi/SendPushMessagePort.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/notification/spi/SendPushMessagePort.kt new file mode 100644 index 00000000..1f42bbca --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/notification/spi/SendPushMessagePort.kt @@ -0,0 +1,19 @@ +package team.comit.simtong.domain.notification.spi + +import java.util.UUID + +/** + * + * 푸시 알림 전송을 요청하는 SendPushMessagePort + * + * @author kimbeomjin + * @date 2022/12/30 + * @version 1.1.0 + **/ +interface SendPushMessagePort { + + fun sendMessage(tokens: List, title: String, content: String, identify: UUID?) + + fun sendMessage(token: String, title: String, content: String, identify: UUID?) + +} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/notification/FcmAdapter.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/notification/FcmAdapter.kt index f1cfbdd6..6ce0c4e2 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/notification/FcmAdapter.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/notification/FcmAdapter.kt @@ -7,6 +7,7 @@ import com.google.firebase.messaging.Message import com.google.firebase.messaging.MulticastMessage import com.google.firebase.messaging.Notification import org.springframework.stereotype.Component +import team.comit.simtong.domain.notification.spi.SendPushMessagePort import java.util.UUID /** @@ -18,9 +19,9 @@ import java.util.UUID * @version 1.1.0 **/ @Component -class FcmAdapter { +class FcmAdapter : SendPushMessagePort { - fun sendMessage(tokens: List, title: String, content: String, identify: UUID) { + override fun sendMessage(tokens: List, title: String, content: String, identify: UUID?) { val multicastMessage = MulticastMessage.builder() .addAllTokens(tokens) .putData("identify", identify.toString()) @@ -40,7 +41,7 @@ class FcmAdapter { FirebaseMessaging.getInstance().sendMulticastAsync(multicastMessage) } - fun sendMessage(token: String, title: String, content: String, identify: UUID) { + override fun sendMessage(token: String, title: String, content: String, identify: UUID?) { val message = Message.builder() .setToken(token) .putData("identify", identify.toString())