- 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>
A chat was unique per user pair, so contacting the same author about a
second ad returned the old chat with the old post_id, and the chat list
showed the other ad's title and image.
- chats are unique per (user_one_id, user_two_id, post_id); migration 015
drops the old pair constraint whatever its name and adds the new one
- getOrCreateChat looks the chat up by users and post, and checks that the
other user exists and the post belongs to one of the participants
- chat list is sorted by last message time (chat creation as fallback)
- WebSocket message and unread events are sent only after commit
- chat errors are ApiException: 404 not found, 403 not a participant,
400 validation; messages are limited to 4000 characters
- Post.images ordered by id so the cover image is stable everywhere
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- getFeed: add id DESC as tie-breaker so posts with equal createdAt
are not duplicated or lost between pages
- moderation: AI verdict false now sets REJECTED instead of ACTIVE
- nightly cleanup: invalidate feed and map caches after deleting posts
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>