Skip to content

Commit

Permalink
Fix :: FCM 파일 혹은 사진 보낼때 링크 알림에 안담기도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yeseong0412 committed Oct 19, 2024
1 parent 18db6a8 commit 5131b76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MessageServiceImpl(

private fun sendAlarm(message: Message, userId: Long) {
fcmService.sendChatAlarm(
message = message.message,
message = message,
chatRoomId = message.chatRoomId,
userId = userId
)
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/com/seugi/api/global/infra/fcm/FCMService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.seugi.api.global.infra.fcm
import com.google.firebase.messaging.FirebaseMessaging
import com.google.firebase.messaging.Message
import com.google.firebase.messaging.Notification
import com.seugi.api.domain.chat.domain.chat.model.Type
import com.seugi.api.domain.chat.domain.room.ChatRoomEntity
import com.seugi.api.domain.chat.domain.room.ChatRoomRepository
import com.seugi.api.domain.chat.exception.ChatErrorCode
Expand Down Expand Up @@ -66,17 +67,17 @@ class FCMService(
.orElseThrow { CustomException(ChatErrorCode.CHAT_ROOM_NOT_FOUND) }
}

fun sendChatAlarm(message: String, chatRoomId: String, userId: Long) {
fun sendChatAlarm(message: com.seugi.api.domain.chat.domain.chat.model.Message, chatRoomId: String, userId: Long) {

val room = findChatRoomById(chatRoomId)

val sendMember = getMember(userId)

if (message.isEmpty()) return
if (message.message.isEmpty()) return

val notification = buildNotification(
title = room.chatName.ifEmpty { "1대1 채팅" },
body = "${sendMember.name.value} : $message",
body = "${sendMember.name.value} : ${if (message.type == Type.FILE) "파일을 보냈습니다." else if (message.type == Type.IMG) "사진을 보냈습니다." else message.message}",
imageUrl = getAlarmImage(workspace = null, type = FCMEnums.CHAT, member = sendMember)
)

Expand Down

0 comments on commit 5131b76

Please sign in to comment.