Skip to content

Commit 8e7bd8e

Browse files
authored
Merge pull request #359 from CODE-LG/refactor/#358
[refactor] 채팅 알람을 제외한 FCM 알람 data.type = NOTICE 추가
2 parents 3b6a292 + b0ad48f commit 8e7bd8e

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/main/kotlin/codel/notification/domain/sender/FcmNotificationSender.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package codel.notification.domain.sender
22

33
import codel.config.Loggable
4+
import codel.notification.domain.NotificationDataType
45
import codel.notification.domain.NotificationType
56
import codel.notification.exception.NotificationException
67
import com.google.firebase.messaging.*
@@ -24,10 +25,10 @@ class FcmNotificationSender : NotificationSender, Loggable {
2425
.build(),
2526
)
2627

27-
// data 필드가 있으면 추가
28-
notification.data?.let { data ->
29-
messageBuilder.putAllData(data)
30-
}
28+
// 기본값으로 NOTICE 타입 설정 후, 요청 data로 덮어쓰기
29+
val defaultData = mapOf("type" to NotificationDataType.NOTICE.value)
30+
val dataToSend = defaultData + (notification.data ?: emptyMap())
31+
messageBuilder.putAllData(dataToSend)
3132

3233
val message = messageBuilder.build()
3334

@@ -62,10 +63,10 @@ class FcmNotificationSender : NotificationSender, Loggable {
6263
.build(),
6364
)
6465

65-
// data 필드가 있으면 추가
66-
notification.data?.let { data ->
67-
messageBuilder.putAllData(data)
68-
}
66+
// 기본값으로 NOTICE 타입 설정 후, 요청 data로 덮어쓰기
67+
val defaultData = mapOf("type" to NotificationDataType.NOTICE.value)
68+
val dataToSend = defaultData + (notification.data ?: emptyMap())
69+
messageBuilder.putAllData(dataToSend)
6970

7071
messageBuilder.build()
7172
}

0 commit comments

Comments
 (0)