Skip to content

Commit

Permalink
HOTFIX: add RedisListener 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
koreaioi committed Nov 9, 2024
1 parent 1740fb8 commit b2653cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ public ResponseDto<ChatRoomResponseDto> existChatRoom(@PathVariable Long user1Id

return ResponseDto.response(GET_ROOMID.getCode(), GET_ROOMID.getMessage(), response);
}

@PostMapping("/{roomId}") // addListener 테스트 용
public void addListener(@PathVariable @NotNull Long roomId) {
chatRoomService.addListener(roomId);
log.info(roomId+":addListener");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public ChatRoomResponseDto findUser1User2ChatRoom(Long user1Id , Long user2Id) {
.orElseThrow(NotFoundChatRoomException::new);
return new ChatRoomResponseDto(result);
}

// 테스트를 위해서 만들어둠. 추후 삭제
public void addListener(Long roomId) {
redisMessageListener.adaptMessageListener(roomId); // 리스너 등록
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.leets.X.domain.chat.entity.ChatMessage;
import com.leets.X.domain.chat.entity.ChatRoom;
import com.leets.X.domain.chat.exception.NotFoundChatRoomException;
import com.leets.X.domain.chat.redis.RedisListener;
import com.leets.X.domain.chat.repository.ChatMessageRepository;
import com.leets.X.domain.chat.repository.ChatRoomRepository;
import com.leets.X.domain.user.domain.User;
Expand All @@ -24,11 +25,13 @@ public class ChattingService {

private final ChatRoomRepository chatRoomRepository;
private final ChatMessageRepository chatMessageRepository;
private final RedisListener redisMessageListener;

public ChattingDto getChatRoom(Long roomId, Integer page, Integer size) {
ChatRoom findRoom = validateChatRoom(roomId);
User user1 = findRoom.getUser1();
User user2 = findRoom.getUser2();
redisMessageListener.adaptMessageListener(findRoom.getId()); // 채팅방 내역 조회시 리스너 등록 추가 (운영 시 삭제)

List<ChatMessageResponseDto> chatMessageList = generateChatRoomMessages(roomId, page, size);
return new ChattingDto(user1.getId(), user2.getId(), user1.getCustomId(), user2.getCustomId(), chatMessageList);
Expand Down

0 comments on commit b2653cb

Please sign in to comment.