feat: redundant role removal and service import

adriano 2024-04-03 15:04:51 -03:00
parent 20a45b6210
commit d6ec5972a5
2 changed files with 11 additions and 13 deletions

View File

@ -94,9 +94,6 @@ export async function findByContain(
} }
return results; return results;
} }
export async function del(key: string) {
await redis.del(key);
}
export async function createObject({ export async function createObject({
whatsappId, whatsappId,

View File

@ -85,7 +85,6 @@ import {
} from "../../helpers/WhatsappIdMultiSessionControl"; } from "../../helpers/WhatsappIdMultiSessionControl";
import AppError from "../../errors/AppError"; import AppError from "../../errors/AppError";
import { setMessageAsRead } from "../../helpers/SetMessageAsRead"; import { setMessageAsRead } from "../../helpers/SetMessageAsRead";
import FindOrCreateTicketServiceBot from "../TicketServices/FindOrCreateTicketServiceBot";
import { getSettingValue } from "../../helpers/WhaticketSettings"; import { getSettingValue } from "../../helpers/WhaticketSettings";
import { Op, json } from "sequelize"; import { Op, json } from "sequelize";
@ -95,10 +94,12 @@ import mostRepeatedPhrase from "../../helpers/MostRepeatedPhrase";
import ListWhatsAppsNumber from "../WhatsappService/ListWhatsAppsNumber"; import ListWhatsAppsNumber from "../WhatsappService/ListWhatsAppsNumber";
import { import {
createObject, createObject,
del,
findByContain, findByContain,
findObject, findObject,
get, get,
getSimple getSimple,
set
} from "../../helpers/RedisClient"; } from "../../helpers/RedisClient";
import FindOrCreateTicketServiceBot from "../TicketServices/FindOrCreateTicketServiceBot"; import FindOrCreateTicketServiceBot from "../TicketServices/FindOrCreateTicketServiceBot";
import ShowTicketService from "../TicketServices/ShowTicketService"; import ShowTicketService from "../TicketServices/ShowTicketService";
@ -106,6 +107,7 @@ import ShowQueuesByUser from "../UserServices/ShowQueuesByUser";
import ListWhatsappQueuesByUserQueue from "../UserServices/ListWhatsappQueuesByUserQueue"; import ListWhatsappQueuesByUserQueue from "../UserServices/ListWhatsappQueuesByUserQueue";
import CreateContactService from "../ContactServices/CreateContactService"; import CreateContactService from "../ContactServices/CreateContactService";
import { number } from "yup"; import { number } from "yup";
import ShowContactCustomFieldService from "../ContactServices/ShowContactCustomFieldsService";
var lst: any[] = getWhatsappIds(); var lst: any[] = getWhatsappIds();
@ -1199,9 +1201,9 @@ const handleMessage = async (
return; return;
} }
let query = await get( let query = await get({
`whatsappId:${wbot.id}:contactId:${contact?.id}:identifier:query` key: `whatsappId:${wbot.id}:contactId:${contact?.id}:identifier:query`
); });
if (query && msg?.body?.trim() != "0") { if (query && msg?.body?.trim() != "0") {
query = JSON.parse(query); query = JSON.parse(query);
@ -1218,8 +1220,7 @@ const handleMessage = async (
if (query?.value?.trim()?.length == 0) { if (query?.value?.trim()?.length == 0) {
await set( await set(
`whatsappId:${wbot.id}:contactId:${contact?.id}:identifier:query`, `whatsappId:${wbot.id}:contactId:${contact?.id}:identifier:query`,
JSON.stringify({ ...query, value: msg.body }), JSON.stringify({ ...query, value: msg.body }),
true
); );
} }
@ -1264,8 +1265,7 @@ dialog_actions=request_endpoint=https://sos.espacolaser.com.br/api/whatsapp/tick
queryMsg: menuMsg?.queryMsg, queryMsg: menuMsg?.queryMsg,
queryMsgInvalidParam: menuMsg?.queryMsgInvalidParam, queryMsgInvalidParam: menuMsg?.queryMsgInvalidParam,
optionsMenu: menuMsg?.optionsMenu optionsMenu: menuMsg?.optionsMenu
}), }),
true
); );
} }
} }
@ -1459,7 +1459,8 @@ const menu = async (userTyped: string, whatsappId: any, contactId: any) => {
whatsappId, whatsappId,
contactId, contactId,
identifier: "ura", identifier: "ura",
value: data[1].id value: data[1].id,
history: `|${data[1].id}`
}); });
await del( await del(