git commit -m "fix: Correct marking of bot messages from Omnihit application to be ignored upon return. Updated the frontend to chaining the notify data "

feat-scaling-ticket-remote-creation
adriano 2024-03-21 09:16:31 -03:00
parent 52e63706c1
commit 84896ec09c
4 changed files with 26 additions and 40 deletions

View File

@ -80,7 +80,7 @@ const UpdateTicketService = async ({
if (msg?.trim().length > 0) {
setTimeout(async () => {
sendWhatsAppMessageSocket(ticket, msg);
sendWhatsAppMessageSocket(ticket, `\u200e${msg}`);
}, 2000);
}

View File

@ -392,7 +392,7 @@ const verifyQueue = async (
if (outService.length > 0) {
const { type, msg: msgOutService } = outService[0];
console.log(`${type} message ignored on queue`);
botSendMessage(ticket, msgOutService);
botSendMessage(ticket, `\u200e${msgOutService}`);
return;
}
@ -642,26 +642,9 @@ const handleMessage = async (
// let groupContact: Contact | undefined;
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
// 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"
// in this case, return and let this message be handled by "media_uploaded" event, when it will have "hasMedia = true"
@ -933,6 +916,7 @@ const handleMessage = async (
ticket.status == "pending" &&
ticket.queueId
) {
if (botInfo.isOnQueue) {
let choosenQueue = await ShowQueueService(botInfo.botQueueId);
await UpdateTicketService({
@ -945,13 +929,15 @@ const handleMessage = async (
});
const menuMsg: any = await menu(msg.body, wbot.id, contact.id);
await botSendMessage(ticket, menuMsg.value);
}
return;
} else if (
!msg.fromMe &&
msg.body == "#" &&
ticket.status == "pending" &&
ticket.queueId
ticket.queueId &&
botInfo.isOnQueue
) {
let choosenQueue = await ShowQueueService(botInfo.botQueueId);
@ -1002,7 +988,7 @@ const handleMessage = async (
return;
}
botSendMessage(ticket, msgOutService);
botSendMessage(ticket, `\u200e${msgOutService}`);
return;
}
}

View File

@ -269,7 +269,7 @@ const NotificationsPopOver = () => {
if(!isQueue && notify){
return;
}else{
const notification = new Notification(`${i18n.t("tickets.notification.messagePeding")} ${notify.data.queue?.name}`);
const notification = new Notification(`${i18n.t("tickets.notification.messagePeding")} ${notify?.data?.queue?.name}`);
notification.onclick = e => {
e.preventDefault()
window.focus()