Skip to content

fix : 알림 도메인 RedisConfig 리스너 추가 및 이미지 전송 NPE 이슈 수정#154

Merged
chuuminggg merged 21 commits into
mainfrom
feature/notification/message
Apr 7, 2026
Merged

fix : 알림 도메인 RedisConfig 리스너 추가 및 이미지 전송 NPE 이슈 수정#154
chuuminggg merged 21 commits into
mainfrom
feature/notification/message

Conversation

@chuuminggg
Copy link
Copy Markdown
Member

🔥ISSUE

Redis 알림 발행 시 구독자가 등록되지 않아 WebSocket으로 알림이 전달되지 않는 문제 및
채팅방 목록 조회 시 이미지 메시지의 마지막 메시지 내용이 비어있는 문제 수정

📒TODO

  1. RedisConfig에 RedisNotificationSubscriber를 redisMessageListenerContainer에 등록
  2. notification:user:* 패턴으로 Redis 알림 구독 처리 추가
  3. ChatMessage가 IMAGE 타입일 경우 lastMessageContent를 "[이미지]"로 반환하도록 수정

📋REF

  • 원인: RedisNotificationSubscriber가 리스너로 등록되지 않아 publish된 알림을 수신하지 못함
  • 수정 후 흐름:
    알림 생성 → Redis publish(notification:user:3)
    → RedisNotificationSubscriber 수신
    → WebSocket /topic/notification.3 전송
    → 클라이언트 수신
  • 채팅 버그 원인:
    ChatMessage.content는 "", 이미지 URL은 fileUrl에만 존재하지만 getContent()만 참조하여 lastMessageContent가 비어있던 문제 발생
  • 개선 사항:
    IMAGE 타입 메시지는 "[이미지]"로 표시하도록 처리

@chuuminggg chuuminggg requested review from ekdan38 and jaey-oung April 6, 2026 13:01
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +157 to +158
.collect(Collectors.toMap(User::getId,
u -> u.getNickname() != null ? u.getNickname() : "시스템"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

사용자 닉네임이 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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 메서드에서 생성되는 message는 senderNickname을 포함하는데, 만약 발신자(sender)는 존재하지만 닉네임이 null인 경우 senderNickname이 null이 되어 "null님이 스킬 교환을 요청했습니다."와 같은 부적절한 메시지가 생성될 수 있습니다. 72번 라인의 닉네임 추출 로직에서 null 및 빈 문자열에 대한 기본값 처리를 강화하는 것이 좋습니다.

…nk 통합 처리, 시스템 알림과 탈퇴/미설정 유저 구분, toMap merge function 추가로 중복 키 예외 방지)
Copy link
Copy Markdown
Collaborator

@jaey-oung jaey-oung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다. 고생하셨어요!

@chuuminggg chuuminggg merged commit 582d8ee into main Apr 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants