create chats only together with the first message

- GET /api/v1/chats/with/{otherUserId}?postId= finds an existing chat
  (404 if there is none) and never creates one
- POST /api/v1/chats/with/{otherUserId}/messages?postId= with {content}
  finds or creates the chat and saves the first message in one
  transaction; same participant/post checks as before, WebSocket events
  still sent after commit
- the old POST /with/{otherUserId} that created empty chats is removed
- chat list hides chats without messages (existing empty rows stay in DB)
- empty messages are rejected with 400

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
SlimusMinus
2026-10-13 01:45:18 +03:00
parent 73463f6c5b
commit cd0d2a4081
5 changed files with 102 additions and 18 deletions

View File

@@ -0,0 +1,9 @@
package com.krylov.refound.dto;
import lombok.Data;
/** Первое сообщение, с которым создаётся чат. */
@Data
public class StartChatRequest {
private String content;
}