Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 이전 채팅내역 조회 response 수정 및 response 경로 변경 #58

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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