Alteração no cache

pull/21/head
adriano 2022-12-23 13:35:07 -03:00
parent 7c7627873c
commit 2c6b6c7309
5 changed files with 44 additions and 14 deletions

View File

@ -18,7 +18,7 @@ const autoRestore = async (whatsappId: string | number, started_action_by: strin
// console.log('>>>>>>>>>>> Whatsapp.id: ', whatsappId)
restartWhatsSession(whatsapp, true)
await restartWhatsSession(whatsapp, true)
const sourcePath = path.join(__dirname, `../../.wwebjs_auth/sessions/log`)

View File

@ -0,0 +1,24 @@
// require fs module
const fs = require("fs");
// Delete a directory and its children
export const creationTime = (sourcePath: string) => {
if (fs.existsSync(sourcePath)) {
try {
const { birthtime } = fs.statSync(sourcePath)
return birthtime
} catch (error) {
console.log(`There was an error on trying get de file/directory creation info from ${sourcePath}: `, error)
}
}
return
}

View File

@ -142,7 +142,7 @@ export const getRestoreControll = () => {
export const _restore = async (whatsapp: Whatsapp, msg_file_title: string) => {
if (whatsapp.status != 'RESTORING') {
if (whatsapp.status != 'RESTORING' && whatsapp.status != 'qrcode') {
console.log('THE WHATSAAP ID: ', whatsapp.id, ' WILL BE RESTORED SOON!')

View File

@ -117,6 +117,7 @@ async function searchWhatsappCache(id: string, status: string) {
const number_cache: any = await redis.hgetall(`whatsapp:${id}`)
if(Object.entries(number_cache).length == 0){
redis.quit()
return []
}

View File

@ -10,7 +10,14 @@ import { getRestoreControll, setRestoreControll, shifRestoreControll } from "../
import ShowWhatsAppService from "../WhatsappService/ShowWhatsAppService";
import { restartWhatsSession } from "../../helpers/RestartWhatsSession";
import dir from 'path';
import autoRestore from "../../helpers/AutoRestore";
import { creationTime } from "../../helpers/CreationTime";
import { splitDateTime } from "../../helpers/SplitDateTime";
import { format } from "date-fns";
import ptBR from 'date-fns/locale/pt-BR';
let lstAutoRestore: any = []
@ -21,8 +28,6 @@ export const StartWhatsAppSession = async (whatsapp: Whatsapp, backupSession: bo
status: "OPENING",
})
try {
let lstRestore: any = getRestoreControll()