Merge pull request #46 from SlimusMinus/fix-chat-per-post
All checks were successful
deploy-backend / deploy (push) Successful in 1m21s
All checks were successful
deploy-backend / deploy (push) Successful in 1m21s
Fix chat per post
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.krylov.refound.controller;
|
package com.krylov.refound.controller;
|
||||||
|
|
||||||
import com.krylov.refound.dto.SendMessageRequest;
|
import com.krylov.refound.dto.SendMessageRequest;
|
||||||
|
import com.krylov.refound.exception.ApiException;
|
||||||
import com.krylov.refound.service.ChatService;
|
import com.krylov.refound.service.ChatService;
|
||||||
import com.krylov.refound.util.TimeZoneContext;
|
import com.krylov.refound.util.TimeZoneContext;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -47,7 +48,7 @@ public class ChatWebSocketController {
|
|||||||
Object timezone = sessionAttributes.get(TimeZoneContext.SESSION_ATTRIBUTE);
|
Object timezone = sessionAttributes.get(TimeZoneContext.SESSION_ATTRIBUTE);
|
||||||
TimeZoneContext.set(timezone instanceof String tz ? tz : null);
|
TimeZoneContext.set(timezone instanceof String tz ? tz : null);
|
||||||
chatService.sendMessage(senderId, request.getChatId(), request.getContent());
|
chatService.sendMessage(senderId, request.getChatId(), request.getContent());
|
||||||
} catch (SecurityException | IllegalArgumentException e) {
|
} catch (ApiException | IllegalArgumentException e) {
|
||||||
messagingTemplate.convertAndSendToUser(senderId.toString(), "/queue/errors", e.getMessage()
|
messagingTemplate.convertAndSendToUser(senderId.toString(), "/queue/errors", e.getMessage()
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import lombok.ToString;
|
|||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "chats", uniqueConstraints = {@UniqueConstraint(columnNames = {"user_one_id", "user_two_id"})})
|
@Table(name = "chats", uniqueConstraints = {@UniqueConstraint(name = "uq_chat_users_post", columnNames = {"user_one_id", "user_two_id", "post_id"})})
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import jakarta.persistence.GenerationType;
|
|||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.OrderBy;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -58,7 +59,9 @@ public class Post {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
// Порядок загрузки: первая картинка (обложка в ленте, чатах, на карте) должна быть стабильной
|
||||||
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
|
@OrderBy("id ASC")
|
||||||
private List<Image> images = new ArrayList<>();
|
private List<Image> images = new ArrayList<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import org.springframework.data.repository.query.Param;
|
|||||||
|
|
||||||
public interface ChatRepository extends JpaRepository<Chat, Long> {
|
public interface ChatRepository extends JpaRepository<Chat, Long> {
|
||||||
|
|
||||||
@Query("SELECT c FROM Chat c WHERE c.userOneId = :u1 AND c.userTwoId = :u2")
|
/** Чат пары пользователей по конкретному объявлению (postId == null — чат без объявления). */
|
||||||
Optional<Chat> findByUsers(Long u1, Long u2);
|
@Query("SELECT c FROM Chat c WHERE c.userOneId = :u1 AND c.userTwoId = :u2 "
|
||||||
|
+ "AND ((:postId IS NULL AND c.postId IS NULL) OR c.postId = :postId)")
|
||||||
|
List<Chat> findByUsersAndPost(Long u1, Long u2, Long postId);
|
||||||
|
|
||||||
/** Есть ли пользователь среди участников чата. Имя не следует конвенции Spring Data, потому что запрос задан явно. */
|
/** Есть ли пользователь среди участников чата. Имя не следует конвенции Spring Data, потому что запрос задан явно. */
|
||||||
@Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM Chat c "
|
@Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM Chat c "
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ import com.krylov.refound.dto.MessageDto;
|
|||||||
import com.krylov.refound.entity.Chat;
|
import com.krylov.refound.entity.Chat;
|
||||||
import com.krylov.refound.entity.Image;
|
import com.krylov.refound.entity.Image;
|
||||||
import com.krylov.refound.entity.Message;
|
import com.krylov.refound.entity.Message;
|
||||||
|
import com.krylov.refound.entity.Post;
|
||||||
|
import com.krylov.refound.enums.ErrorCode;
|
||||||
|
import com.krylov.refound.exception.ApiException;
|
||||||
import com.krylov.refound.repository.ChatRepository;
|
import com.krylov.refound.repository.ChatRepository;
|
||||||
import com.krylov.refound.repository.MessageRepository;
|
import com.krylov.refound.repository.MessageRepository;
|
||||||
import com.krylov.refound.repository.PostRepository;
|
import com.krylov.refound.repository.PostRepository;
|
||||||
import com.krylov.refound.repository.UserRepository;
|
import com.krylov.refound.repository.UserRepository;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -17,15 +22,21 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronization;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ChatService {
|
public class ChatService {
|
||||||
|
|
||||||
|
/** Максимальная длина сообщения в символах. */
|
||||||
|
public static final int MAX_MESSAGE_LENGTH = 4000;
|
||||||
|
|
||||||
private final ChatRepository chatRepository;
|
private final ChatRepository chatRepository;
|
||||||
private final MessageRepository messageRepository;
|
private final MessageRepository messageRepository;
|
||||||
private final SimpMessagingTemplate messagingTemplate;
|
private final SimpMessagingTemplate messagingTemplate;
|
||||||
@@ -36,13 +47,27 @@ public class ChatService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public ChatDto getOrCreateChat(Long currentUserId, Long otherUserId, Long postId) {
|
public ChatDto getOrCreateChat(Long currentUserId, Long otherUserId, Long postId) {
|
||||||
if (currentUserId.equals(otherUserId)) {
|
if (currentUserId.equals(otherUserId)) {
|
||||||
throw new IllegalArgumentException("Нельзя создать чат с самим собой");
|
throw new ApiException(ErrorCode.VALIDATION_ERROR, "Нельзя создать чат с самим собой", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
if (!userRepository.existsById(otherUserId)) {
|
||||||
|
throw new ApiException(ErrorCode.NOT_FOUND, "Пользователь не найден", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
if (postId != null) {
|
||||||
|
// Иначе клиент мог прикрепить к чату любое чужое объявление
|
||||||
|
Post post = postRepository.findById(postId)
|
||||||
|
.orElseThrow(() -> new ApiException(ErrorCode.NOT_FOUND, "Объявление не найдено", HttpStatus.NOT_FOUND));
|
||||||
|
Long ownerId = post.getUser().getId();
|
||||||
|
if (!ownerId.equals(currentUserId) && !ownerId.equals(otherUserId)) {
|
||||||
|
throw new ApiException(ErrorCode.VALIDATION_ERROR, "Объявление не принадлежит участнику чата", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Long userId1 = Math.min(currentUserId, otherUserId);
|
Long userId1 = Math.min(currentUserId, otherUserId);
|
||||||
Long userId2 = Math.max(currentUserId, otherUserId);
|
Long userId2 = Math.max(currentUserId, otherUserId);
|
||||||
|
|
||||||
Chat chat = chatRepository.findByUsers(userId1, userId2).orElseGet(() -> {
|
// Чат отдельный на каждое объявление: иначе обращение к тому же автору по другому
|
||||||
|
// объявлению возвращало старый чат с чужим postId (и чужой картинкой в списке чатов)
|
||||||
|
Chat chat = chatRepository.findByUsersAndPost(userId1, userId2, postId).stream().findFirst().orElseGet(() -> {
|
||||||
Chat newChat = new Chat();
|
Chat newChat = new Chat();
|
||||||
newChat.setUserOneId(userId1);
|
newChat.setUserOneId(userId1);
|
||||||
newChat.setUserTwoId(userId2);
|
newChat.setUserTwoId(userId2);
|
||||||
@@ -53,11 +78,19 @@ public class ChatService {
|
|||||||
return toDto(chat, currentUserId);
|
return toDto(chat, currentUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Все чаты пользователя
|
// Все чаты пользователя: сверху чаты с самым свежим сообщением (или самые новые, если сообщений нет)
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<ChatDto> getUserChats(Long userId) {
|
public List<ChatDto> getUserChats(Long userId) {
|
||||||
|
record ChatWithActivity(ChatDto dto, LocalDateTime lastActivity) {
|
||||||
|
}
|
||||||
|
|
||||||
return chatRepository.findAllByUserId(userId).stream()
|
return chatRepository.findAllByUserId(userId).stream()
|
||||||
.map(c -> toDto(c, userId))
|
.map(c -> {
|
||||||
|
ChatDto dto = toDto(c, userId);
|
||||||
|
return new ChatWithActivity(dto, dto.getLastMessageAt() != null ? dto.getLastMessageAt() : c.getCreatedAt());
|
||||||
|
})
|
||||||
|
.sorted(Comparator.comparing(ChatWithActivity::lastActivity, Comparator.nullsLast(Comparator.reverseOrder())))
|
||||||
|
.map(ChatWithActivity::dto)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +106,11 @@ public class ChatService {
|
|||||||
// Отправка сообщения (вызывается из WebSocket контроллера)
|
// Отправка сообщения (вызывается из WebSocket контроллера)
|
||||||
@Transactional
|
@Transactional
|
||||||
public void sendMessage(Long senderId, Long chatId, String content) {
|
public void sendMessage(Long senderId, Long chatId, String content) {
|
||||||
|
if (content.length() > MAX_MESSAGE_LENGTH) {
|
||||||
|
throw new ApiException(ErrorCode.VALIDATION_ERROR,
|
||||||
|
"Сообщение длиннее " + MAX_MESSAGE_LENGTH + " символов", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
Chat chat = getChatOrThrow(chatId);
|
Chat chat = getChatOrThrow(chatId);
|
||||||
checkParticipant(chat, senderId);
|
checkParticipant(chat, senderId);
|
||||||
|
|
||||||
@@ -84,8 +122,6 @@ public class ChatService {
|
|||||||
|
|
||||||
MessageDto dto = toMessageDto(message);
|
MessageDto dto = toMessageDto(message);
|
||||||
|
|
||||||
messagingTemplate.convertAndSend("/topic/chat/" + chatId, dto);
|
|
||||||
|
|
||||||
// Уведомляем получателя об непрочитанных
|
// Уведомляем получателя об непрочитанных
|
||||||
Long recipientId = chat.getUserOneId().equals(senderId)
|
Long recipientId = chat.getUserOneId().equals(senderId)
|
||||||
? chat.getUserTwoId()
|
? chat.getUserTwoId()
|
||||||
@@ -93,11 +129,28 @@ public class ChatService {
|
|||||||
|
|
||||||
long unreadCount = messageRepository.countByChatIdAndIsReadFalseAndSenderIdNot(chatId, recipientId);
|
long unreadCount = messageRepository.countByChatIdAndIsReadFalseAndSenderIdNot(chatId, recipientId);
|
||||||
|
|
||||||
messagingTemplate.convertAndSend(
|
// Рассылаем только после коммита: иначе клиент, получив событие и перезапросив
|
||||||
"/topic/user/" + recipientId + "/unread",
|
// историю, мог не увидеть ещё не закоммиченное сообщение
|
||||||
Map.of("chatId", chatId, "unreadCount", unreadCount)
|
afterCommit(() -> {
|
||||||
);
|
messagingTemplate.convertAndSend("/topic/chat/" + chatId, dto);
|
||||||
|
messagingTemplate.convertAndSend(
|
||||||
|
"/topic/user/" + recipientId + "/unread",
|
||||||
|
Map.of("chatId", chatId, "unreadCount", unreadCount)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void afterCommit(Runnable action) {
|
||||||
|
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||||
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
|
@Override
|
||||||
|
public void afterCommit() {
|
||||||
|
action.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
action.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -128,12 +181,13 @@ public class ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Chat getChatOrThrow(Long chatId) {
|
private Chat getChatOrThrow(Long chatId) {
|
||||||
return chatRepository.findById(chatId).orElseThrow(() -> new IllegalArgumentException("Чат не найден"));
|
return chatRepository.findById(chatId)
|
||||||
|
.orElseThrow(() -> new ApiException(ErrorCode.NOT_FOUND, "Чат не найден", HttpStatus.NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkParticipant(Chat chat, Long userId) {
|
private void checkParticipant(Chat chat, Long userId) {
|
||||||
if (!chat.getUserOneId().equals(userId) && !chat.getUserTwoId().equals(userId)) {
|
if (!chat.getUserOneId().equals(userId) && !chat.getUserTwoId().equals(userId)) {
|
||||||
throw new SecurityException("Вы не участник этого чата");
|
throw new ApiException(ErrorCode.FORBIDDEN, "Вы не участник этого чата", HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
databaseChangeLog:
|
||||||
|
- changeSet:
|
||||||
|
id: 015-chats-unique-per-post
|
||||||
|
author: krylov
|
||||||
|
comment: >
|
||||||
|
Чат теперь уникален для пары пользователей И объявления. Раньше уникальной была
|
||||||
|
только пара, и при обращении к тому же автору по другому объявлению возвращался
|
||||||
|
старый чат со старым post_id (не та картинка во вкладке чатов).
|
||||||
|
Имя старого ограничения может отличаться (таблицу раньше создавал Hibernate),
|
||||||
|
поэтому удаляем любое unique-ограничение ровно по (user_one_id, user_two_id).
|
||||||
|
preConditions:
|
||||||
|
onFail: MARK_RAN
|
||||||
|
tableExists:
|
||||||
|
tableName: chats
|
||||||
|
changes:
|
||||||
|
- sql:
|
||||||
|
splitStatements: false
|
||||||
|
sql: |
|
||||||
|
DO $$
|
||||||
|
DECLARE r record;
|
||||||
|
BEGIN
|
||||||
|
FOR r IN
|
||||||
|
SELECT con.conname
|
||||||
|
FROM pg_constraint con
|
||||||
|
JOIN pg_class t ON t.oid = con.conrelid
|
||||||
|
WHERE t.relname = 'chats'
|
||||||
|
AND con.contype = 'u'
|
||||||
|
AND (SELECT array_agg(a.attname::text ORDER BY a.attname::text)
|
||||||
|
FROM pg_attribute a
|
||||||
|
WHERE a.attrelid = t.oid AND a.attnum = ANY (con.conkey))
|
||||||
|
= ARRAY['user_one_id', 'user_two_id']
|
||||||
|
LOOP
|
||||||
|
EXECUTE format('ALTER TABLE chats DROP CONSTRAINT %I', r.conname);
|
||||||
|
END LOOP;
|
||||||
|
END $$;
|
||||||
|
- addUniqueConstraint:
|
||||||
|
tableName: chats
|
||||||
|
columnNames: user_one_id, user_two_id, post_id
|
||||||
|
constraintName: uq_chat_users_post
|
||||||
@@ -29,3 +29,4 @@ databaseChangeLog:
|
|||||||
- include: { file: db/changelog/create/006-create-chats.yaml }
|
- include: { file: db/changelog/create/006-create-chats.yaml }
|
||||||
- include: { file: db/changelog/add/017-messages-chat-id.yaml }
|
- include: { file: db/changelog/add/017-messages-chat-id.yaml }
|
||||||
- include: { file: db/changelog/alter/014-posts-rules-accepted-type.yaml }
|
- include: { file: db/changelog/alter/014-posts-rules-accepted-type.yaml }
|
||||||
|
- include: { file: db/changelog/alter/015-chats-unique-per-post.yaml }
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package com.krylov.refound.service;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import com.krylov.refound.dto.ChatDto;
|
||||||
|
import com.krylov.refound.entity.Chat;
|
||||||
|
import com.krylov.refound.entity.Post;
|
||||||
|
import com.krylov.refound.entity.User;
|
||||||
|
import com.krylov.refound.exception.ApiException;
|
||||||
|
import com.krylov.refound.repository.ChatRepository;
|
||||||
|
import com.krylov.refound.repository.MessageRepository;
|
||||||
|
import com.krylov.refound.repository.PostRepository;
|
||||||
|
import com.krylov.refound.repository.UserRepository;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
|
|
||||||
|
class ChatServiceTest {
|
||||||
|
|
||||||
|
private ChatRepository chatRepository;
|
||||||
|
private UserRepository userRepository;
|
||||||
|
private PostRepository postRepository;
|
||||||
|
private ChatService chatService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
chatRepository = mock(ChatRepository.class);
|
||||||
|
userRepository = mock(UserRepository.class);
|
||||||
|
postRepository = mock(PostRepository.class);
|
||||||
|
MessageRepository messageRepository = mock(MessageRepository.class);
|
||||||
|
chatService = new ChatService(chatRepository, messageRepository, mock(SimpMessagingTemplate.class),
|
||||||
|
userRepository, postRepository);
|
||||||
|
|
||||||
|
when(userRepository.existsById(anyLong())).thenReturn(true);
|
||||||
|
when(messageRepository.findFirstByChatIdOrderByCreatedAtDesc(any())).thenReturn(Optional.empty());
|
||||||
|
when(chatRepository.findByUsersAndPost(any(), any(), any())).thenReturn(List.of());
|
||||||
|
when(chatRepository.save(any(Chat.class))).thenAnswer(inv -> {
|
||||||
|
Chat chat = inv.getArgument(0);
|
||||||
|
chat.setId(100L);
|
||||||
|
return chat;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postOwnedBy(long postId, long ownerId) {
|
||||||
|
User owner = new User();
|
||||||
|
owner.setId(ownerId);
|
||||||
|
Post post = new Post();
|
||||||
|
post.setId(postId);
|
||||||
|
post.setUser(owner);
|
||||||
|
when(postRepository.findById(postId)).thenReturn(Optional.of(post));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void createsChatAboutPostOfOtherUser() {
|
||||||
|
postOwnedBy(41L, 19L);
|
||||||
|
|
||||||
|
ChatDto chat = chatService.getOrCreateChat(14L, 19L, 41L);
|
||||||
|
|
||||||
|
assertThat(chat.getPostId()).isEqualTo(41L);
|
||||||
|
assertThat(chat.getOtherUserId()).isEqualTo(19L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsPostOfThirdUser() {
|
||||||
|
postOwnedBy(41L, 7L);
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> chatService.getOrCreateChat(14L, 19L, 41L))
|
||||||
|
.isInstanceOfSatisfying(ApiException.class, e -> assertThat(e.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsChatWithYourself() {
|
||||||
|
assertThatThrownBy(() -> chatService.getOrCreateChat(19L, 19L, 41L))
|
||||||
|
.isInstanceOf(ApiException.class)
|
||||||
|
.hasMessageContaining("самим собой");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user