Fazendo ajuste para diferenciar o whastapp pelo numero
parent
d23a826385
commit
1b79ce1a55
|
@ -1,13 +1,29 @@
|
||||||
import { Op } from "sequelize";
|
import { Op } from "sequelize";
|
||||||
import AppError from "../errors/AppError";
|
import AppError from "../errors/AppError";
|
||||||
import Ticket from "../models/Ticket";
|
import Ticket from "../models/Ticket";
|
||||||
|
import ListWhatsAppsNumber from "../services/WhatsappService/ListWhatsAppsNumber";
|
||||||
|
|
||||||
const CheckContactOpenTickets = async (contactId: number | string, whatsappId: number | string): Promise<void> => {
|
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({
|
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) {
|
if (ticket) {
|
||||||
throw new AppError("ERR_OTHER_OPEN_TICKET");
|
throw new AppError("ERR_OTHER_OPEN_TICKET");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ const CreateTicketService = async ({
|
||||||
console.log('matchingQueue: ', matchingQueue)
|
console.log('matchingQueue: ', matchingQueue)
|
||||||
const queueId = matchingQueue ? matchingQueue.queueId : undefined
|
const queueId = matchingQueue ? matchingQueue.queueId : undefined
|
||||||
|
|
||||||
|
console.log('contactId, defaultWhatsapp.id: ',contactId, defaultWhatsapp.id)
|
||||||
|
|
||||||
await CheckContactOpenTickets(contactId, defaultWhatsapp.id);
|
await CheckContactOpenTickets(contactId, defaultWhatsapp.id);
|
||||||
|
|
||||||
const { isGroup } = await ShowContactService(contactId);
|
const { isGroup } = await ShowContactService(contactId);
|
||||||
|
|
Loading…
Reference in New Issue