Skip to content
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 @@ -7,8 +7,8 @@
import com.brainpix.message.model.Message;

public interface MessageRepository extends MongoRepository<Message, String> {
Page<Message> findByReceiverIdOrSenderId(Long senderId, Long receiverId, Pageable pageable);
Page<Message> findAllByReceiverId(Long receiverId, Pageable pageable);
Page<Message> findAllByReceiverIdAndIsRead(Long receiverId, Boolean isRead, Pageable pageable);
Page<Message> findAllBySenderId(Long senderId, Pageable pageable);
Long countAllByReceiverIdAndIsRead(Long receiverId, Boolean isRead);
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private User getUser(Long userId, ErrorCode errorCode) {
private Page<Message> getMessageListBySearchType(Long userId, MessageSearchType searchType,
PageRequest pageRequest) {
if (searchType == MessageSearchType.ALL) {
return messageRepository.findAllByReceiverId(userId, pageRequest);
return messageRepository.findByReceiverIdOrSenderId(userId, userId, pageRequest);
} else if (searchType == MessageSearchType.SEND) {
return messageRepository.findAllBySenderId(userId, pageRequest);
} else if (searchType == MessageSearchType.RECEIVED) {
Expand Down