Módulo Ticket
src/app/modules/ticket/
Representa una conversación/caso de soporte entre un contacto y los agentes.
Modelo — Ticket
| Campo | Tipo | Descripción |
|---|---|---|
_id | ObjectId | ID de MongoDB |
tenantId | ObjectId → Tenant | — |
contactId | ObjectId → Contact | Contacto asociado |
status | string | OPEN | IN_PROGRESS | CLOSED |
priority | string | LOW | MEDIUM | HIGH |
lastMessage | ObjectId → Message | Último mensaje (para previews) |
unreadCount | number | Mensajes no leídos por el agente |
createdAt | Date | — |
updatedAt | Date | — |
Endpoints
| Método | Ruta | Auth | Descripción |
|---|---|---|---|
GET | /api/v1/tickets | @Auth() | Lista tickets (filtrable) |
GET | /api/v1/tickets/:id | @Auth() | Obtiene un ticket |
PATCH | /api/v1/tickets/:id | @Auth() | Actualiza status/priority |
DELETE | /api/v1/tickets/:id | @Auth() | Elimina ticket |
TicketsFilterDto
Permite filtrar tickets por status, priority, contactId, tenantId y paginar.
Creación automática
El ChatGateway crea tickets automáticamente cuando un CONTACT inicia una conversación nueva (evento AUTHENTICATE + CREATE_ROOM). No se crean manualmente.
Tests
El módulo incluye:
ticket.service.spec.ts— tests unitarios del servicioticket.service.integration.spec.ts— tests de integración (usa BD real, controlado porTESTING)