|
|
@ -392,7 +392,7 @@ const verifyQueue = async (
|
|
|
|
if (outService.length > 0) {
|
|
|
|
if (outService.length > 0) {
|
|
|
|
const { type, msg: msgOutService } = outService[0];
|
|
|
|
const { type, msg: msgOutService } = outService[0];
|
|
|
|
console.log(`${type} message ignored on queue`);
|
|
|
|
console.log(`${type} message ignored on queue`);
|
|
|
|
botSendMessage(ticket, msgOutService);
|
|
|
|
botSendMessage(ticket, `\u200e${msgOutService}`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -644,26 +644,9 @@ const handleMessage = async (
|
|
|
|
// let groupContact: Contact | undefined;
|
|
|
|
// let groupContact: Contact | undefined;
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.fromMe) {
|
|
|
|
if (msg.fromMe) {
|
|
|
|
const whatsapp = await whatsappInfo(wbot.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (whatsapp?.number) {
|
|
|
|
|
|
|
|
const ticketExpiration = await SettingTicket.findOne({
|
|
|
|
|
|
|
|
where: { key: "ticketExpiration", number: whatsapp.number }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
ticketExpiration &&
|
|
|
|
|
|
|
|
ticketExpiration.value == "enabled" &&
|
|
|
|
|
|
|
|
ticketExpiration?.message.trim() == msg.body.trim()
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
console.log("*********** TICKET EXPIRATION");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// messages sent automatically by wbot have a special character in front of it
|
|
|
|
// messages sent automatically by wbot have a special character in front of it
|
|
|
|
// if so, this message was already been stored in database;
|
|
|
|
// if so, this message was already been stored in database;
|
|
|
|
// if (/\u200e/.test(msg.body[0])) return;
|
|
|
|
if (/\u200e/.test(msg.body[0])) return;
|
|
|
|
|
|
|
|
|
|
|
|
// media messages sent from me from cell phone, first comes with "hasMedia = false" and type = "image/ptt/etc"
|
|
|
|
// media messages sent from me from cell phone, first comes with "hasMedia = false" and type = "image/ptt/etc"
|
|
|
|
// in this case, return and let this message be handled by "media_uploaded" event, when it will have "hasMedia = true"
|
|
|
|
// in this case, return and let this message be handled by "media_uploaded" event, when it will have "hasMedia = true"
|
|
|
@ -935,25 +918,28 @@ const handleMessage = async (
|
|
|
|
ticket.status == "pending" &&
|
|
|
|
ticket.status == "pending" &&
|
|
|
|
ticket.queueId
|
|
|
|
ticket.queueId
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let choosenQueue = await ShowQueueService(botInfo.botQueueId);
|
|
|
|
if (botInfo.isOnQueue) {
|
|
|
|
|
|
|
|
let choosenQueue = await ShowQueueService(botInfo.botQueueId);
|
|
|
|
|
|
|
|
|
|
|
|
await UpdateTicketService({
|
|
|
|
await UpdateTicketService({
|
|
|
|
ticketData: {
|
|
|
|
ticketData: {
|
|
|
|
status: "open",
|
|
|
|
status: "open",
|
|
|
|
userId: botInfo.userIdBot,
|
|
|
|
userId: botInfo.userIdBot,
|
|
|
|
queueId: choosenQueue.id
|
|
|
|
queueId: choosenQueue.id
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ticketId: ticket.id
|
|
|
|
ticketId: ticket.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const menuMsg: any = await menu(msg.body, wbot.id, contact.id);
|
|
|
|
const menuMsg: any = await menu(msg.body, wbot.id, contact.id);
|
|
|
|
await botSendMessage(ticket, menuMsg.value);
|
|
|
|
await botSendMessage(ticket, menuMsg.value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else if (
|
|
|
|
} else if (
|
|
|
|
!msg.fromMe &&
|
|
|
|
!msg.fromMe &&
|
|
|
|
msg.body == "#" &&
|
|
|
|
msg.body == "#" &&
|
|
|
|
ticket.status == "pending" &&
|
|
|
|
ticket.status == "pending" &&
|
|
|
|
ticket.queueId
|
|
|
|
ticket.queueId &&
|
|
|
|
|
|
|
|
botInfo.isOnQueue
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let choosenQueue = await ShowQueueService(botInfo.botQueueId);
|
|
|
|
let choosenQueue = await ShowQueueService(botInfo.botQueueId);
|
|
|
|
|
|
|
|
|
|
|
@ -1004,7 +990,7 @@ const handleMessage = async (
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
botSendMessage(ticket, msgOutService);
|
|
|
|
botSendMessage(ticket, `\u200e${msgOutService}`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|