feat: enhance messaging system with improved API and tests
- Refactor messaging API endpoints for admin, shop, and vendor - Add message-specific exceptions (ConversationNotFoundException, etc.) - Enhance messaging service with additional helper methods - Add comprehensive test fixtures for messaging - Add integration tests for admin and vendor messaging APIs - Add unit tests for messaging and attachment services 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -103,8 +103,11 @@ from .inventory import (
|
||||
|
||||
# Message exceptions
|
||||
from .message import (
|
||||
AttachmentNotFoundException,
|
||||
ConversationClosedException,
|
||||
ConversationNotFoundException,
|
||||
InvalidConversationTypeException,
|
||||
InvalidRecipientTypeException,
|
||||
MessageAttachmentException,
|
||||
MessageNotFoundException,
|
||||
UnauthorizedConversationAccessException,
|
||||
@@ -389,4 +392,7 @@ __all__ = [
|
||||
"ConversationClosedException",
|
||||
"MessageAttachmentException",
|
||||
"UnauthorizedConversationAccessException",
|
||||
"InvalidConversationTypeException",
|
||||
"InvalidRecipientTypeException",
|
||||
"AttachmentNotFoundException",
|
||||
]
|
||||
|
||||
@@ -61,3 +61,40 @@ class UnauthorizedConversationAccessException(BusinessLogicException):
|
||||
error_code="CONVERSATION_ACCESS_DENIED",
|
||||
details={"conversation_id": conversation_id},
|
||||
)
|
||||
|
||||
|
||||
class InvalidConversationTypeException(ValidationException):
|
||||
"""Raised when conversation type is not valid for the operation."""
|
||||
|
||||
def __init__(self, message: str, allowed_types: list[str] | None = None):
|
||||
super().__init__(
|
||||
message=message,
|
||||
error_code="INVALID_CONVERSATION_TYPE",
|
||||
details={"allowed_types": allowed_types} if allowed_types else None,
|
||||
)
|
||||
|
||||
|
||||
class InvalidRecipientTypeException(ValidationException):
|
||||
"""Raised when recipient type doesn't match conversation type."""
|
||||
|
||||
def __init__(self, conversation_type: str, expected_recipient_type: str):
|
||||
super().__init__(
|
||||
message=f"{conversation_type} conversations require a {expected_recipient_type} recipient",
|
||||
error_code="INVALID_RECIPIENT_TYPE",
|
||||
details={
|
||||
"conversation_type": conversation_type,
|
||||
"expected_recipient_type": expected_recipient_type,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class AttachmentNotFoundException(ResourceNotFoundException):
|
||||
"""Raised when an attachment is not found."""
|
||||
|
||||
def __init__(self, attachment_id: int | str):
|
||||
super().__init__(
|
||||
resource_type="Attachment",
|
||||
identifier=str(attachment_id),
|
||||
message=f"Attachment '{attachment_id}' not found",
|
||||
error_code="ATTACHMENT_NOT_FOUND",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user