20 lines
640 B
Python
20 lines
640 B
Python
from uuid import UUID
|
|
|
|
from apps.chat.models import Conversation, ConversationReport, ReportReason
|
|
|
|
|
|
class ReportService:
|
|
def create(
|
|
self,
|
|
conversation_uuid: UUID,
|
|
reporter_uuid: UUID,
|
|
reason: str,
|
|
other_reason_text: str | None = None,
|
|
) -> ConversationReport:
|
|
conversation = Conversation.objects.get(uuid=conversation_uuid)
|
|
return ConversationReport.objects.create(
|
|
conversation=conversation,
|
|
reporter_uuid=reporter_uuid,
|
|
reason=reason,
|
|
other_reason_text=other_reason_text if reason == ReportReason.OTHER else None,
|
|
)
|