Skip to content

Commit

Permalink
♻️ :: 코드리뷰 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
lyutvs committed May 11, 2023
1 parent b246ec1 commit b38bd65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ enum class ErrorCode(

INTERNAL_SERVER_ERROR(500, "GLOBAL-500-1", "Internal Server Error."),

DEVICE_TOKEN_LENGTH(400, "DEVICE-400-1", "Device Token Length Error.");
DEVICE_TOKEN_LENGTH(400, "DEVICE-400-1", "Device Token Length Error.")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.v1servicenotification.error

class NotificationDeviceTokenLengthException private constructor(): NotificationException(ErrorCode.DETAIL_NOT_FOUND) {
class NotificationDeviceTokenLengthException private constructor(): NotificationException(ErrorCode.DEVICE_TOKEN_LENGTH) {

companion object {
@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import com.google.firebase.messaging.MulticastMessage
import com.google.firebase.messaging.Notification
import io.github.v1servicenotification.detail.spi.PostDetailFcmSpi
import io.github.v1servicenotification.error.NotificationDeviceTokenLengthException
import io.github.v1servicenotification.error.NotificationException
import org.springframework.stereotype.Service

@Service
class FcmService: PostDetailFcmSpi {

companion object {
const val MAX_TOKEN_LENGTH = 163
}

override fun sendGroupMessage(tokenList: List<String>, title: String, content: String, threadId: String) {
val validTokens = tokenList.filter { it.length == 163 }
val validTokens = tokenList.filter { it.length == MAX_TOKEN_LENGTH }
if (validTokens.isNotEmpty()) {
val multicast = MulticastMessage.builder()
.addAllTokens(validTokens)
Expand All @@ -41,7 +44,7 @@ class FcmService: PostDetailFcmSpi {
}

override fun sendMessage(token: String, title: String, content: String, threadId: String) {
if (token.length >= 163) {
if (token.length >= MAX_TOKEN_LENGTH) {
val message = Message.builder()
.setToken(token)
.setNotification(
Expand Down

0 comments on commit b38bd65

Please sign in to comment.