Fixes: 1) Replace generic serializers with context-specific implementations in schema definitions. Extra: 1) Minor code cleanup and reorganization for improved readability and maintainability; 2) Add comments for new serializers.
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from drf_spectacular.utils import OpenApiParameter
|
|
|
|
from engine.vibes_auth.messaging.serializers import (
|
|
StaffInboxEventSerializer,
|
|
ThreadOkResponseSerializer,
|
|
ThreadReplyRequestSerializer,
|
|
UserMessageRequestSerializer,
|
|
UserMessageResponseSerializer,
|
|
)
|
|
|
|
USER_MESSAGE_CONSUMER_SCHEMA = {
|
|
"tags": [
|
|
"messaging",
|
|
],
|
|
"type": "send",
|
|
"summary": _("User messages entrypoint"),
|
|
"description": _("Anonymous or authenticated non-staff users send messages. Also supports action=ping."),
|
|
"request": UserMessageRequestSerializer,
|
|
"responses": UserMessageResponseSerializer,
|
|
}
|
|
|
|
STAFF_INBOX_CONSUMER_SCHEMA = {
|
|
"tags": [
|
|
"messaging",
|
|
],
|
|
"type": "send",
|
|
"summary": _("Staff inbox control"),
|
|
"description": _("Staff-only actions: list_open, assign, reply, close, ping. Unified event payloads are emitted."),
|
|
"request": StaffInboxEventSerializer,
|
|
"responses": StaffInboxEventSerializer,
|
|
}
|
|
|
|
THREAD_CONSUMER_SCHEMA = {
|
|
"tags": [
|
|
"messaging",
|
|
],
|
|
"type": "send",
|
|
"summary": _("Per-thread staff channel"),
|
|
"description": _("Reply, close, and ping within a specific thread."),
|
|
"parameters": [OpenApiParameter(name="thread_id")],
|
|
"request": ThreadReplyRequestSerializer,
|
|
"responses": ThreadOkResponseSerializer,
|
|
}
|