fix : 알림 도메인 RedisConfig 리스너 추가 및 이미지 전송 NPE 이슈 수정#154
Conversation
…P-Link-it/backend into feature/notification/message
…eature/notification/message
There was a problem hiding this comment.
Code Review
This pull request enhances the chat and notification systems. It introduces a helper method in ChatRoomService to display "[이미지]" for image-type messages and updates the notification logic to include descriptive messages. Performance is improved in NotificationServiceImpl by batch-fetching sender nicknames. Additionally, Redis configuration is updated to support notification subscriptions. Feedback focuses on improving nickname null-handling to prevent "null" strings in messages and to distinguish between unknown users and system notifications, as well as adding a merge function to the nickname map collection for robustness.
| .collect(Collectors.toMap(User::getId, | ||
| u -> u.getNickname() != null ? u.getNickname() : "시스템")); |
There was a problem hiding this comment.
사용자 닉네임이 null이거나 빈 문자열인 경우에 대한 처리가 필요합니다. 현재 로직으로는 닉네임이 없는 사용자를 "시스템"으로 표시하고 있는데, 이는 실제 시스템 알림(senderId가 null인 경우)과 혼동을 줄 수 있습니다. 사용자의 경우 "알 수 없음" 등으로 구분하여 표시하는 것이 좋습니다. 또한, Collectors.toMap 사용 시 만약의 중복 키 발생 상황을 대비해 병합 함수(merge function)를 제공하는 것이 안전합니다.
.collect(Collectors.toMap(User::getId, u -> (u.getNickname() != null && !u.getNickname().isBlank()) ? u.getNickname() : "알 수 없음", (existing, replacement) -> existing));|
|
||
| log.info("알림 생성 및 발송: receiverId={}, type={}, refId={}", receiverId, type, refId); | ||
| return NotificationDto.from(savedNotification); | ||
| return NotificationDto.from(savedNotification, message); |
…nk 통합 처리, 시스템 알림과 탈퇴/미설정 유저 구분, toMap merge function 추가로 중복 키 예외 방지)
🔥ISSUE
Redis 알림 발행 시 구독자가 등록되지 않아 WebSocket으로 알림이 전달되지 않는 문제 및
채팅방 목록 조회 시 이미지 메시지의 마지막 메시지 내용이 비어있는 문제 수정
📒TODO
📋REF
알림 생성 → Redis publish(notification:user:3)
→ RedisNotificationSubscriber 수신
→ WebSocket /topic/notification.3 전송
→ 클라이언트 수신
ChatMessage.content는 "", 이미지 URL은 fileUrl에만 존재하지만 getContent()만 참조하여 lastMessageContent가 비어있던 문제 발생
IMAGE 타입 메시지는 "[이미지]"로 표시하도록 처리