fix: corrections and improvements to support two goal numbers
Details: - Made corrections and improvements to the codebase to support handling two goal numbers.gertec
parent
da86bbfa33
commit
bf2dc3de03
|
@ -47,3 +47,4 @@ npm-debug.log*
|
|||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
dump.rdb
|
||||
|
|
|
@ -96,7 +96,7 @@ export const customization = async (
|
|||
req: Request,
|
||||
res: Response
|
||||
): Promise<Response> => {
|
||||
const { ura } = req.body;
|
||||
const { ura, number } = req.body;
|
||||
|
||||
if (!ura) throw new AppError("BAD REQUEST", 400);
|
||||
|
||||
|
@ -183,15 +183,16 @@ export const customization = async (
|
|||
// await set("ura", ura);
|
||||
}
|
||||
}
|
||||
|
||||
await set(`ura_${number}`, ura);
|
||||
|
||||
await set("ura", ura);
|
||||
|
||||
const _ura = await get({ key: "ura", parse: true });
|
||||
console.log("_URA: ", _ura);
|
||||
const _ura = await get({ key: `ura_${number}`, parse: true });
|
||||
console.log(`ura_${number}`, _ura);
|
||||
|
||||
return res.status(200).json({ new_queues });
|
||||
};
|
||||
|
||||
|
||||
export const show = async (req: Request, res: Response): Promise<Response> => {
|
||||
const { queueId } = req.params;
|
||||
|
||||
|
|
|
@ -13,17 +13,17 @@ async function controllByNumber() {
|
|||
let controll: any[] = [];
|
||||
|
||||
for (const ticket of tickets) {
|
||||
let match = ticket.match(/"whatsappId":(\d+)/);
|
||||
let match = ticket?.match(/"whatsappId":(\d+)/);
|
||||
let whatsappId = match ? match[1] : null;
|
||||
|
||||
const whatsapp = await get({
|
||||
key: `whatsapp:${whatsappId}`
|
||||
});
|
||||
|
||||
match = whatsapp.match(/"number":"(\d+)"/);
|
||||
match = whatsapp?.match(/"number":"(\d+)"/);
|
||||
let number = match ? match[1] : null;
|
||||
|
||||
match = ticket.match(/"id":(\d+)/);
|
||||
match = ticket?.match(/"id":(\d+)/);
|
||||
let ticketId = match ? match[1] : null;
|
||||
|
||||
number = JSON.parse(number);
|
||||
|
@ -42,17 +42,18 @@ async function controllByNumber() {
|
|||
|
||||
for (const ticketId of ticketIds) {
|
||||
const ticket: any = await Ticket.findByPk(ticketId);
|
||||
|
||||
const { status } = ticket;
|
||||
|
||||
if (status == "pending") {
|
||||
await UpdateTicketService({
|
||||
ticketData: { statusChatEnd: uuidv4() },
|
||||
ticketId: ticket.id
|
||||
});
|
||||
if(ticket){
|
||||
const { status } = ticket;
|
||||
|
||||
if (status == "pending") {
|
||||
await UpdateTicketService({
|
||||
ticketData: { statusChatEnd: uuidv4() },
|
||||
ticketId: ticket.id
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set(`remote:controll`, JSON.stringify(ticketIds));
|
||||
|
||||
return { ticketIds, tickets };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { join } from "path";
|
||||
import { promisify } from "util";
|
||||
import { writeFile } from "fs";
|
||||
import { writeFile, promises } from "fs";
|
||||
import * as Sentry from "@sentry/node";
|
||||
|
||||
import { copyFolder } from "../../helpers/CopyFolder";
|
||||
|
@ -8,6 +8,7 @@ import { removeDir } from "../../helpers/DeleteDirectory";
|
|||
import path from "path";
|
||||
import { cpf, cnpj } from 'cpf-cnpj-validator';
|
||||
|
||||
|
||||
import {
|
||||
isHoliday,
|
||||
isOutBusinessTime,
|
||||
|
@ -108,7 +109,7 @@ import CreateContactService from "../ContactServices/CreateContactService";
|
|||
import { number } from "yup";
|
||||
import AssociateContatctQueue from "../ContactServices/AssociateContatctQueue";
|
||||
import ContactQueue from "../../models/ContactQueues";
|
||||
|
||||
import SendWhatsAppMedia from "./SendWhatsAppMedia";
|
||||
var lst: any[] = getWhatsappIds();
|
||||
|
||||
interface Session extends Client {
|
||||
|
@ -1167,7 +1168,8 @@ const menu = async (userTyped: string, whatsappId: any, contactId: any, ticket:
|
|||
|
||||
if(!LGPDSaves && option.id === '1400' && userTyped.toLowerCase() === 'ok' && contactData){
|
||||
contactData.isLGPDAccepted = true;
|
||||
await updateContactService({contactData, contactId});
|
||||
const plainContactData = contactData.get({ plain: true });
|
||||
await updateContactService({contactData: plainContactData, contactId});
|
||||
}
|
||||
|
||||
let history: any = await historyUra(whatsappId, contactId, response.id);
|
||||
|
@ -1268,9 +1270,10 @@ const menu = async (userTyped: string, whatsappId: any, contactId: any, ticket:
|
|||
|
||||
if (contactData && contactData.name != userTyped) {
|
||||
contactData.name = userTyped;
|
||||
await updateContactService({contactData, contactId});
|
||||
const plainContactData = contactData.get({ plain: true });
|
||||
await updateContactService({contactData: plainContactData, contactId});
|
||||
}
|
||||
botSendMessage(
|
||||
await botSendMessage(
|
||||
ticket,
|
||||
`O protocolo desse atendimento é: ${ticket?.id}.`
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue