Skip to content

Commit

Permalink
Merge pull request #58 from Domitory-CheckMate/feature/57-chat
Browse files Browse the repository at this point in the history
[fix] 이전 채팅내역 조회 response 수정 및 response 경로 변경
  • Loading branch information
RyuKwanKon authored Jan 23, 2024
2 parents 95948cd + d56c3b4 commit ba98181
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ public class ChatController {
public void sendChat(@Header("simpSessionAttributes") Map<String, Object> simpSessionAttributes,
@Payload final ChatRequestDto request) {
ChatResponseDto response = chatService.sendChat(simpSessionAttributes, request);
sendingOperations.convertAndSend("/queue/chat/"+simpSessionAttributes.get("roomId"), SocketBaseResponse.of(MessageType.CHAT, response));
sendingOperations.convertAndSend("/queue/chat/" + simpSessionAttributes.get("roomId"), SocketBaseResponse.of(MessageType.CHAT, response));
}

// 채팅방 정보 조회
@MessageMapping("/room-list")
public void getChatRoomList(@Header("simpSessionAttributes") Map<String, Object> simpSessionAttributes) {
ChatRoomListResponseDto response = chatService.getChatRoomList(simpSessionAttributes);
sendingOperations.convertAndSend("/queue/user/"+simpSessionAttributes.get("userId"), SocketBaseResponse.of(MessageType.ROOM_LIST, response));
sendingOperations.convertAndSend("/queue/user/" + simpSessionAttributes.get("userId"), SocketBaseResponse.of(MessageType.ROOM_LIST, response));
}

// 이전 채팅 불러오기
@MessageMapping("/chat-list")
public void getChatList(@Header("simpSessionAttributes") Map<String, Object> simpSessionAttributes,
@Payload final ChatListRequestDto request) {
final ChatListResponseDto response = chatService.getChatList(simpSessionAttributes, request);
sendingOperations.convertAndSend("/queue/user/" + simpSessionAttributes.get("userId"), SocketBaseResponse.of(MessageType.CHAT_LIST, response));
ChatListResponseDto response = chatService.getChatList(simpSessionAttributes, request);
sendingOperations.convertAndSend("/queue/chat/" + response.getChatRoomId(), SocketBaseResponse.of(MessageType.CHAT_LIST, response));
}

// 채팅방 입장하기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class ChatListResponseDto{

private String chatRoomId;

private Long requestUserId;

private ChatUserInfoDto chatUserInfoDto;

@Builder.Default
Expand All @@ -26,9 +28,10 @@ public class ChatListResponseDto{
@Builder.Default
private Integer pageNumber = null;

public static ChatListResponseDto of(String chatRoomId, ChatUserInfoDto chatUserInfoDto) {
public static ChatListResponseDto of(String chatRoomId, Long requestUserId, ChatUserInfoDto chatUserInfoDto) {
return ChatListResponseDto.builder()
.chatRoomId(chatRoomId)
.requestUserId(requestUserId)
.chatUserInfoDto(chatUserInfoDto)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ChatListResponseDto getChatList(Map<String, Object> simpSessionAttributes
String chatRoomId = getChatRoomId(request.otherUserId(), userId);

ChatUserInfoDto chatUserInfoDto = getUserChatUserInfoByUserId(request);
ChatListResponseDto response = ChatListResponseDto.of(chatRoomId, chatUserInfoDto);
ChatListResponseDto response = ChatListResponseDto.of(chatRoomId, userId, chatUserInfoDto);

PageRequest pageRequest = PageRequest.of(request.pageNumber(), request.pageSize());
Slice<Chat> chatMessages = chatRepository.findBeforeChatList(chatRoomId, pageRequest);
Expand Down

0 comments on commit ba98181

Please sign in to comment.