forked from mtusi2026/mtusi2026lab3
fix
This commit is contained in:
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.mtusi.messenger.dto.ChatDTO;
|
||||
import ru.mtusi.messenger.dto.ChatPageDTO;
|
||||
import ru.mtusi.messenger.dto.CreateChatDTO;
|
||||
import ru.mtusi.messenger.exception.InvalidRequestException;
|
||||
import ru.mtusi.messenger.exception.NotFoundException;
|
||||
import ru.mtusi.messenger.mapper.ChatMapper;
|
||||
@@ -28,15 +29,15 @@ public class ChatService {
|
||||
private final ChatRepository chatRepository;
|
||||
|
||||
@Transactional
|
||||
public ChatDTO createChat(UUID caller, ChatDTO chatDTO) {
|
||||
Set<User> members = chatValidator.validateCreate(caller, chatDTO);
|
||||
Chat chat = buildChat(chatDTO, members);
|
||||
public ChatDTO createChat(UUID caller, CreateChatDTO createChatDTO) {
|
||||
Set<User> members = chatValidator.validateCreate(caller, createChatDTO);
|
||||
Chat chat = buildChat(createChatDTO, members);
|
||||
chat = persistChat(chat);
|
||||
return chatMapper.toChatDto(chat);
|
||||
}
|
||||
|
||||
private Chat buildChat(ChatDTO chatDTO, Set<User> members) {
|
||||
Chat chat = chatMapper.toChat(chatDTO);
|
||||
private Chat buildChat(CreateChatDTO createChatDTO, Set<User> members) {
|
||||
Chat chat = chatMapper.toChat(createChatDTO);
|
||||
chat.setMembers(members);
|
||||
return chat;
|
||||
}
|
||||
@@ -93,13 +94,13 @@ public class ChatService {
|
||||
}
|
||||
|
||||
private CursorCodec.Cursor parseChatsCursor(String cursor) {
|
||||
if (cursor == null || cursor.isBlank()) {
|
||||
if (cursor == null)
|
||||
return null;
|
||||
}
|
||||
if (cursor.isEmpty())
|
||||
throw new InvalidRequestException("Cursor must not be empty");
|
||||
CursorCodec.Cursor decoded = CursorCodec.decode(cursor);
|
||||
if (decoded.scopeId() != null) {
|
||||
if (decoded.scopeId() != null)
|
||||
throw new InvalidRequestException("Invalid cursor");
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user