Implementação parcial do session out
parent
c334de3cfb
commit
5c44656328
|
@ -0,0 +1,62 @@
|
|||
const fsPromises = require("fs/promises");
|
||||
const fs = require('fs')
|
||||
import axios from 'axios';
|
||||
import * as https from "https";
|
||||
|
||||
|
||||
const sendMessageAPI = async (url: string, body: string) => {
|
||||
|
||||
let response: any = null
|
||||
|
||||
try {
|
||||
|
||||
const httpsAgent = new https.Agent({ rejectUnauthorized: false, });
|
||||
|
||||
response = await axios.post(url, {
|
||||
'x-api-token': 'e23dcfdfeb6be5b91b1bf5c55ee50cc4405f2802',
|
||||
'x-api-app': 'x-api-app',
|
||||
}, {
|
||||
httpsAgent,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
console.log(`TEST URL CLIENT POST ROUTE: ${url} | STATUS CODE: ${response.status}`);
|
||||
|
||||
|
||||
|
||||
// if (method == 'get') {
|
||||
// // const url = 'https://sos.espacolaser.com.br/api/whatsapp/ticket/R32656'
|
||||
// response = await axios.get(url, {
|
||||
// httpsAgent,
|
||||
// headers: {
|
||||
// 'x-access-token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOnsiaWQiOjEsInJvbGUiOiJjbGllbnQiLCJob3N0Ijoic29zLmVzcGFjb2xhc2VyLmNvbS5iciIsInRlbmFudCI6ImVzcGFjb2xhc2VyIiwibmFtZSI6IlNFTlNSLklUIiwiY29tcGFueSI6eyJpZCI6NDR9fSwiZGF0ZSI6MTY2MTI2MjY0MywiaWF0IjoxNjYxMjYyNjQzLCJleHAiOjE3NDc2NjI2NDN9.zf91OmRs4_C7B8OlVpLLrQMiRBYc7edP4qAdH_hqxpk',
|
||||
// 'Origin': 'espacolaser'
|
||||
// }
|
||||
// });
|
||||
// console.log(`TEST URL CLIENT GET ROUTE: ${url} | STATUS CODE: ${response.status}`);
|
||||
// }
|
||||
// else if (method == 'post') {
|
||||
|
||||
// // const url = 'http://177.107.193.124:8095/labs/zabbix-frontend/api/api.php'
|
||||
|
||||
// response = await axios.post(url, {
|
||||
// 'auth': '0424bd59b807674191e7d77572075f33',
|
||||
// 'jsonrpc': '2.0',
|
||||
// 'method': 'chamado.ematendimento',
|
||||
// 'params[ccusto]': param,
|
||||
// id: '101'
|
||||
// }, {
|
||||
// httpsAgent,
|
||||
// headers: { 'Content-Type': 'multipart/form-data' },
|
||||
// });
|
||||
// console.log(`TEST URL CLIENT POST ROUTE: ${url} | STATUS CODE: ${response.status}`);
|
||||
// }
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Erro ao consultar endpoint ${url}: ${error}`);
|
||||
}
|
||||
|
||||
return response
|
||||
|
||||
}
|
||||
|
||||
export default sendMessageAPI;
|
|
@ -17,24 +17,34 @@ import { loadContactsCache } from "../../helpers/ContactsCache";
|
|||
import { loadSchedulesCache } from "../../helpers/SchedulingNotifyCache";
|
||||
import { createSessionDir } from "../../helpers/CreateSessionDir";
|
||||
|
||||
import openSocket from "socket.io-client";
|
||||
|
||||
|
||||
let counter = 0
|
||||
|
||||
export const StartAllWhatsAppsSessions = async (): Promise<void> => {
|
||||
|
||||
|
||||
|
||||
console.log('KKKKKKKKKKKKKKKKKKKKKKKK')
|
||||
|
||||
const io = require("socket.io-client");
|
||||
const socket = io("http://localhost:8020/", {
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
|
||||
const cacheLength = await cacheSize()
|
||||
|
||||
console.log('cacheSize: ', cacheLength)
|
||||
|
||||
|
||||
|
||||
if (cacheLength == 0) {
|
||||
console.log('Loading from cache...')
|
||||
await flushCache()
|
||||
await loadContactsCache()
|
||||
await loadTicketsCache()
|
||||
}
|
||||
|
||||
|
||||
await loadSchedulesCache()
|
||||
// await loadWhatsappCache()
|
||||
|
||||
|
|
Loading…
Reference in New Issue