from chat.models import Message
from django.db.models import QuerySet

class MessageRepository:

    def get_messages_by_ticket(self, ticket_id: int) -> QuerySet[Message]:
        return Message.objects.filter(ticket_id=ticket_id).select_related('sender')

    def create_message(self, **data):
        # data = {ticket_id, sender, content, message_type}
        return Message.objects.create(**data)