Fazendo ajuste para diferenciar o whastapp pelo numero

adriano 2023-06-21 14:22:23 -03:00
parent d23a826385
commit 1b79ce1a55
2 changed files with 19 additions and 1 deletions

View File

@ -1,13 +1,29 @@
import { Op } from "sequelize";
import AppError from "../errors/AppError";
import Ticket from "../models/Ticket";
import ListWhatsAppsNumber from "../services/WhatsappService/ListWhatsAppsNumber";
const CheckContactOpenTickets = async (contactId: number | string, whatsappId: number | string): Promise<void> => {
// let whats = await ListWhatsAppsNumber(whatsappId)
// console.log('----> whats: ', whats)
const ticket = await Ticket.findOne({
where: { contactId, whatsappId, status: { [Op.or]: ["open", "pending"] } }
// where: { contactId, whatsappId, status: { [Op.or]: ["open", "pending"] } }
where: {
[Op.and]: [
{ contactId: contactId },
{ whatsappId: whatsappId },
{ status: { [Op.or]: ["open", "pending"] } },
]
}
});
console.log('>>>>>>>>>>>>>> ticket: ', (JSON.parse(JSON.stringify(ticket))))
if (ticket) {
throw new AppError("ERR_OTHER_OPEN_TICKET");
}

View File

@ -55,6 +55,8 @@ const CreateTicketService = async ({
console.log('matchingQueue: ', matchingQueue)
const queueId = matchingQueue ? matchingQueue.queueId : undefined
console.log('contactId, defaultWhatsapp.id: ',contactId, defaultWhatsapp.id)
await CheckContactOpenTickets(contactId, defaultWhatsapp.id);
const { isGroup } = await ShowContactService(contactId);