schon/engine/vibes_auth/docs/drf/messaging.py
Egor fureunoir Gorbunov 554769d48e Features: 1) Add detailed serializers for user messages, staff inbox, and thread consumers; 2) Update schema definitions to support new serializers with improved descriptions and summaries; 3) Introduce flexible event-based serializer for staff inbox actions.
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.
2025-11-12 11:37:34 +03:00

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,
}