Skip to content

Commit b42a4f8

Browse files
committed
hotfix: 채팅 푸시알림 형식 수정
1 parent 081ed68 commit b42a4f8

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

src/main/java/com/airfryer/repicka/common/firebase/dto/FCMNotificationReq.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,35 @@ public class FCMNotificationReq {
1515
private NotificationType notificationType;
1616
private String relatedId; // appointmentId, chatId 등
1717
private String relatedName; // 약속 관련 아이템 이름 또는 채팅 상대 이름
18-
19-
// 제목 생성
18+
19+
private String customTitle;
20+
private String customBody;
21+
2022
public String getTitle() {
21-
return notificationType.getTitle();
23+
return customTitle != null ? customTitle : notificationType.getTitle();
2224
}
23-
24-
// 내용 생성
25+
2526
public String getBody() {
26-
return notificationType.getFormattedBody(relatedName);
27+
return customBody != null ? customBody : notificationType.getFormattedBody(relatedName);
2728
}
2829

29-
public static FCMNotificationReq of(NotificationType notificationType, String id, String name) {
30+
public static FCMNotificationReq of(NotificationType notificationType, String id, String name)
31+
{
3032
return FCMNotificationReq.builder()
3133
.notificationType(notificationType)
3234
.relatedId(id)
3335
.relatedName(name)
3436
.build();
3537
}
38+
39+
// 채팅 메시지 전용 팩토리 메서드
40+
public static FCMNotificationReq of(String chatId, String customTitle, String customBody)
41+
{
42+
return FCMNotificationReq.builder()
43+
.notificationType(NotificationType.CHAT_MESSAGE)
44+
.relatedId(chatId)
45+
.customTitle(customTitle)
46+
.customBody(customBody)
47+
.build();
48+
}
3649
}

src/main/java/com/airfryer/repicka/domain/chat/service/ChatWebSocketService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ public void sendMessageChat(User user, ChatRoom chatRoom, Chat chat)
190190
/// 푸시 알림 전송
191191

192192
// 푸시 알림 전송
193-
FCMNotificationReq notificationReq = FCMNotificationReq.of(NotificationType.CHAT_MESSAGE, chat.getId().toHexString(), user.getNickname());
193+
FCMNotificationReq notificationReq = FCMNotificationReq.of(
194+
chat.getId().toHexString(),
195+
"[" + chatRoom.getItem().getTitle() + "] " + user.getNickname(),
196+
chat.getContent()
197+
);
194198
fcmService.sendNotification(opponent.getFcmToken(), notificationReq);
195199

196200
} catch (Exception e) {

0 commit comments

Comments
 (0)