Skip to content

Commit

Permalink
🔀 :: (#136) destination 추가 (#233)
Browse files Browse the repository at this point in the history
* ♻️ :: destination 추가

* ♻️ :: group도 보내도록 추가
  • Loading branch information
jyk1029 authored Aug 6, 2023
1 parent 4c48c0c commit 828a9b7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class NotificationDetailApiImpl(
postDetailUserSpi.getDeviceTokenList(userIdList),
category.title,
content,
threadId
threadId,
category.destination
)
}

Expand Down Expand Up @@ -90,7 +91,8 @@ class NotificationDetailApiImpl(
postDetailUserSpi.getDeviceTokenList(userIdList),
category.title,
content,
threadId
threadId,
category.destination
)
}

Expand Down Expand Up @@ -121,7 +123,7 @@ class NotificationDetailApiImpl(
private fun sendMessage(category: Category, userId: UUID, topic: String, content: String, threadId: String) {
if (category.defaultActivated && postDetailSettingRepositorySpi.findIsActivatedByUserIdAndTopic(userId, topic)) {
// 기본값이 true면 Setting에서 false로 설정한 사람을 제외하고 발송한다.
postDetailFcmSpi.sendMessage(postDetailUserSpi.getDeviceToken(userId), category.title, content, threadId)
postDetailFcmSpi.sendMessage(postDetailUserSpi.getDeviceToken(userId), category.title, content, threadId, category.destination)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.v1servicenotification.detail.spi

interface PostDetailFcmSpi {
fun sendMessage(token: String, title: String, content: String, threadId: String)
fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String)
fun sendMessage(token: String, title: String, content: String, threadId: String, destination: String)
fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String, destination: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package io.github.v1servicenotification.stubs
import io.github.v1servicenotification.detail.spi.PostDetailFcmSpi

class InMemoryFcm: PostDetailFcmSpi {
override fun sendMessage(token: String, title: String, content: String, threadId: String) {
override fun sendMessage(token: String, title: String, content: String, threadId: String, destination: String) {
// TODO("Not yet implemented")
}

override fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String) {
override fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String, destination: String) {
// TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ import java.util.UUID
interface CategoryRepository : CrudRepository<CategoryEntity, UUID> {
fun findAllByDefaultActivated(defaultActivated: Boolean): List<CategoryEntity>
fun existsByTopic(topic: String): Boolean

fun findByTopic(topic: String): CategoryEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ data class Personal(
val content: String,

@JsonProperty("thread_id")
val threadId: String
val threadId: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FcmService: PostDetailFcmSpi {
const val MAX_TOKEN_LENGTH = 163
}

override fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String) {
override fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String, destination: String) {
val validTokens = tokenList.filter { it.length == MAX_TOKEN_LENGTH }
if (validTokens.isNotEmpty()) {
val multicast = MulticastMessage.builder()
Expand All @@ -34,6 +34,7 @@ class FcmService: PostDetailFcmSpi {
Aps.builder()
.setSound("default")
.setThreadId(threadId)
.putCustomData("destination", destination)
.build()
).build()
)
Expand All @@ -43,7 +44,7 @@ class FcmService: PostDetailFcmSpi {
}
}

override fun sendMessage(token: String, title: String, content: String, threadId: String) {
override fun sendMessage(token: String, title: String, content: String, threadId: String, destination: String) {
if (token.length >= MAX_TOKEN_LENGTH) {
val message = Message.builder()
.setToken(token)
Expand All @@ -59,6 +60,7 @@ class FcmService: PostDetailFcmSpi {
Aps.builder()
.setSound("default")
.setThreadId(threadId)
.putCustomData("destination", destination)
.build()
).build()
)
Expand Down

0 comments on commit 828a9b7

Please sign in to comment.