Compare commits

...

3 Commits

3 changed files with 15 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import DeleteUserService from "../services/UserServices/DeleteUserService";
import ListUser from "../services/UserServices/ListUserParamiterService"; import ListUser from "../services/UserServices/ListUserParamiterService";
import User from "../models/User"; import User from "../models/User";
import { get, set } from "../helpers/RedisClient"; import { del, get, set } from "../helpers/RedisClient";
import { import {
startWhoIsOnlineMonitor, startWhoIsOnlineMonitor,
@ -27,7 +27,7 @@ import { splitDateTime } from "../helpers/SplitDateTime";
import ListUserByWhatsappQueuesService from "../services/UserServices/ListUserByWhatsappQueuesService"; import ListUserByWhatsappQueuesService from "../services/UserServices/ListUserByWhatsappQueuesService";
import { json } from "sequelize"; import { json } from "sequelize";
import { getSettingValue } from "../helpers/WhaticketSettings"; import { getSettingValue } from "../helpers/WhaticketSettings";
import { setBotInfo } from "../helpers/SetBotInfo" import { setBotInfo } from "../helpers/SetBotInfo";
type IndexQuery = { type IndexQuery = {
searchParam: string; searchParam: string;
@ -275,7 +275,7 @@ export const update = async (
let user: any = await UpdateUserService({ userData, userId }); let user: any = await UpdateUserService({ userData, userId });
await setBotInfo(user) await setBotInfo(user);
if (user) { if (user) {
const { id, name } = user; const { id, name } = user;
@ -305,6 +305,8 @@ export const remove = async (
await DeleteUserService(userId); await DeleteUserService(userId);
del(`user:${userId}`);
const io = getIO(); const io = getIO();
io.emit("user", { io.emit("user", {
action: "delete", action: "delete",
@ -324,5 +326,3 @@ export const remove = async (
return res.status(200).json({ message: "User deleted" }); return res.status(200).json({ message: "User deleted" });
}; };

View File

@ -42,7 +42,7 @@ import { getSettingValue } from "../helpers/WhaticketSettings";
import ListWhatsAppsNumber from "../services/WhatsappService/ListWhatsAppsNumber"; import ListWhatsAppsNumber from "../services/WhatsappService/ListWhatsAppsNumber";
import SettingTicket from "../models/SettingTicket"; import SettingTicket from "../models/SettingTicket";
import { Op } from "sequelize"; import { Op } from "sequelize";
import { get, set } from "../helpers/RedisClient"; import { del, get, set } from "../helpers/RedisClient";
interface WhatsappData { interface WhatsappData {
name: string; name: string;
@ -230,9 +230,9 @@ export const weebhook = async (
req.body.entry[0].changes[0].value.metadata.display_phone_number; req.body.entry[0].changes[0].value.metadata.display_phone_number;
let type = message.type; let type = message.type;
const contact_from_exist = await get("whatsapp:*", `${contact_from}`); const contact_to_exist = await get("whatsapp:*", `${contact_to}`);
if (!contact_from_exist) { if (contact_to_exist == null) {
console.log( console.log(
"WHATSAPP OFFICIAL", "WHATSAPP OFFICIAL",
" | CONCTACT_FROM: ", " | CONCTACT_FROM: ",
@ -514,6 +514,8 @@ export const remove = async (
}); });
} }
await del(`whatsapp:${whatsappId}`);
let whats = await ListWhatsAppsNumber(whatsappId); let whats = await ListWhatsAppsNumber(whatsappId);
// Remove tickets business hours config // Remove tickets business hours config

View File

@ -23,7 +23,7 @@ export async function get(key: string, value?: string) {
if (keys.length > 0) { if (keys.length > 0) {
for (const key of keys) { for (const key of keys) {
const val = await redis.get(key); const val = await redis.get(key);
if (value == val) return value; if (value == val) return value;
} }
} }
return null; return null;
@ -33,6 +33,10 @@ export async function get(key: string, value?: string) {
} }
} }
export async function del(key: string) {
await redis.del(key);
}
export async function clearAllKeys(...keys: string[]) { export async function clearAllKeys(...keys: string[]) {
for (const key of keys) { for (const key of keys) {
// Retrieve all keys matching the pattern '*' // Retrieve all keys matching the pattern '*'