Alteração no cache
parent
7c7627873c
commit
2c6b6c7309
|
@ -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`)
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
|
@ -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!')
|
||||
|
||||
|
|
|
@ -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 []
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
@ -48,7 +53,7 @@ export const StartWhatsAppSession = async (whatsapp: Whatsapp, backupSession: bo
|
|||
|
||||
console.log('----------------> autoR: ', autoR)
|
||||
|
||||
if (autoR && autoR.whatsappId) {
|
||||
if (autoR && autoR.whatsappId) {
|
||||
|
||||
if (Object.keys(lstRestore.filter((e: any) => +e.id == +autoR.whatsappId)).length) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue