Compare commits

...

2 Commits

Author SHA1 Message Date
adriano 0866cbce79 feat: pending tickets remote at the top of the ticket list 2024-05-22 08:49:43 -03:00
adriano 3574b2d8af feat:disable socket emit event diskSpace 2024-05-14 09:42:07 -03:00
3 changed files with 80 additions and 16 deletions

View File

@ -0,0 +1,44 @@
NODE_ENV=
BACKEND_URL=http://localhost
FRONTEND_URL=http://localhost:3000
PROXY_PORT=8080
PORT=8080
DB_DIALECT=mysql
DB_HOST=localhost
DB_USER=whaticket
DB_PASS=strongpassword
DB_NAME=whaticket
# WHATSAPP OFFICIAL
VERIFY_TOKEN=HAPPY
TOKEN=EAAEPZBB2YqgwBOZBEAvPxYaO2nbPvuzU3ZBaZA6YF6tyWtjKom2yLxPxOm421njhbb1ZC2rOkyQyZCWpZBk9jXZCAaMLNY6SkNOrwPoRNaqO9Fbj31mZC8mxra08jIhBiziX7IZBFDWYbkcfw5cfLdTSys9ilfRlKsIZClOUlTiHnhSDkMvXY6rMFrvWswR2YVvJVH1qPvM7hGuuUqM
VERSION=v17.0
URL_WHATSAPP_MEDIA=https://ccsm-api.omnihit.app.br/whatsapp/official/media
URL_WHATSAPP_API=https://graph.facebook.com
JWT_SECRET=3123123213123
JWT_REFRESH_SECRET=75756756756
SENTRY_DSN=
CACHE=
WHATS_NUMBER_VALIDATOR_URL=http://localhost:8021
TOKEN_REMOTE_TICKET_CREATION=emvd7UfskjstMC99mFqs2tEiNmn05PgsUVK06TZP9LfkyjxDrsKCxlVV5ApYM7hP
TOKEN_IAM_HORACIUS_EL=emvd7UfskjstMC99mFqs2tEiNmn05PgsUVK06TZP9LfkyjxDrsKCxlVV5ApYM7hP
# omnihit da hit test bot
# APP_NAME=recrutamento_el
APP_NAME=test
BACKEND_URL_RAW=http://localhost
PUBLICKEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwOvEh4Qc0yeJidiX3YpDdOB/XuDeyNRaypmSyW5FjjIxBFaMiUmNSZ2X2m2LqyyrHJxQgRqwjifHUQ+ivmNBm4YFNSr05iFB/kgi/1Jmbst6h1MnmuD1YFSRnEsmdUXzhhgcj5btyjRfw6L2rGwOnqzMzS54seE1aAy+rtN82DW8wfbYU/IO83MAJiocthCBOev5MDUq6hdkGPPZ/kdFOLcQe+wt/suhmF4KRfq77X4GgLM5nAOMj7N7cJ6b97nB47krfPOMJissNzPDZ879BKeQX4t8TwJGUFNOvLd3UW3xVBTBz8pSS36VlCXjbYm44za8eTuBLDYYbGkUNEFYxwIDAQAB
REDIS_URI=redis://127.0.0.1:6379
URL_DASHBOARD_SESSIONS=http://localhost:6002
TOKEN_DASHBOARD_SESSIONS=8168dd72adb7bab7e8f54f9d022468ab

View File

@ -104,16 +104,16 @@ const monitor = async () => {
stdout = stdout[1].trim().split(/\s+/);
// DISK SPACE MONITORING
const io = getIO();
io.emit("diskSpaceMonit", {
action: "update",
diskSpace: {
size: stdout[1],
used: stdout[2],
available: stdout[3],
use: stdout[4]
}
});
// const io = getIO();
// io.emit("diskSpaceMonit", {
// action: "update",
// diskSpace: {
// size: stdout[1],
// used: stdout[2],
// available: stdout[3],
// use: stdout[4]
// }
// });
let data: any = {};

View File

@ -1,7 +1,12 @@
import { values } from "sequelize/types/lib/operators";
import Ticket from "../models/Ticket";
import { get, set } from "./RedisClient";
import { getIO } from "../libs/socket";
import UpdateTicketService from "../services/TicketServices/UpdateTicketService";
import { v4 as uuidv4 } from "uuid";
async function controllByNumber() {
let tickets = await get({ key: "remote:ticketId*", parse: false });
let tickets = await get({ key: "remote:ticketId*", parse: false });
if (!tickets) return { ticketIds: [], tickets: null };
@ -9,20 +14,20 @@ async function controllByNumber() {
for (const ticket of tickets) {
let match = ticket.match(/"whatsappId":(\d+)/);
let whatsappId = match ? match[1] : null;
let whatsappId = match ? match[1] : null;
const whatsapp = await get({
key: `whatsapp:${whatsappId}`
});
match = whatsapp.match(/"number":"(\d+)"/);
let number = match ? match[1] : null;
let number = match ? match[1] : null;
match = ticket.match(/"id":(\d+)/);
let ticketId = match ? match[1] : null;
let ticketId = match ? match[1] : null;
number = JSON.parse(number);
ticketId = JSON.parse(ticketId);
ticketId = JSON.parse(ticketId);
const index = controll.findIndex((c: any) => c.number == number);
@ -31,7 +36,22 @@ async function controllByNumber() {
}
}
const ticketIds = controll.map((c: any) => c.ticketId);
const ticketIds = controll.map((c: any) => c.ticketId);
console.log("=======> ticketIds: ", ticketIds);
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
});
}
}
set(`remote:controll`, JSON.stringify(ticketIds));