A message now carries attachment_ids in the request, in every response, in the idempotent replay and in history, in the order they were sent. The chat aggregate checks membership first, then refuses whitespace text, more than ten or repeated attachments, and an empty text without attachments, so an outsider still gets 404 before any 400. The send statement inserts the links next to the message and the idempotency key, and the foreign key from message_attachments to attachments of the same chat turns an unknown or foreign attachment into 404 and rolls the whole send back, without the messaging zone reading the attachments table. Replay and history read the list with a subquery on the primary key. The request fingerprint covers the list, so a missing attachment_ids and [] are the same body while a different order is a conflict. The zone dependency test now covers three zones, and the SQL ownership test checks that every zone touches only its own tables. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
34 lines
466 B
Python
34 lines
466 B
Python
from messenger.shared.domain.errors import DomainError
|
|
|
|
|
|
class MessagingError(DomainError):
|
|
pass
|
|
|
|
|
|
class InvalidChatData(MessagingError):
|
|
pass
|
|
|
|
|
|
class InvalidMessageText(MessagingError):
|
|
pass
|
|
|
|
|
|
class InvalidPageRequest(MessagingError):
|
|
pass
|
|
|
|
|
|
class ChatNotFound(MessagingError):
|
|
pass
|
|
|
|
|
|
class IdempotencyConflict(MessagingError):
|
|
pass
|
|
|
|
|
|
class InvalidAttachmentList(MessagingError):
|
|
pass
|
|
|
|
|
|
class UnknownAttachment(MessagingError):
|
|
pass
|