diff --git a/backend/src/services/MessageServices/ListMessagesService.ts b/backend/src/services/MessageServices/ListMessagesService.ts index cd9854f0..c5785b23 100644 --- a/backend/src/services/MessageServices/ListMessagesService.ts +++ b/backend/src/services/MessageServices/ListMessagesService.ts @@ -2,6 +2,7 @@ import AppError from "../../errors/AppError"; import Message from "../../models/Message"; import Ticket from "../../models/Ticket"; import ShowTicketService from "../TicketServices/ShowTicketService"; +import { Op } from "sequelize"; interface Request { ticketId: string; @@ -42,8 +43,14 @@ const ListMessagesService = async ({ }, { model: Ticket, - where: {contactId: ticket.contactId }, - required: true + where: { + contactId: ticket.contactId, + whatsappId: ticket.whatsappId, + queueId: { + [Op.or]: [ticket.queueId, null], + }, + }, + required: true, } ], offset,