mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
fix: Now when deleting the instance, the data referring to it in mongodb is also deleted
This commit is contained in:
parent
796287a776
commit
897f8164b9
@ -5,6 +5,7 @@
|
||||
* Fix in update settings that needed to restart after updated
|
||||
* Correction in the use of the api with mongodb
|
||||
* Adjustments to search endpoint for contacts, chats, messages and Status messages
|
||||
* Now when deleting the instance, the data referring to it in mongodb is also deleted
|
||||
|
||||
# 1.3.1 (2023-07-20 07:48)
|
||||
|
||||
|
@ -18,6 +18,16 @@ import { Db } from 'mongodb';
|
||||
import { initInstance } from '../whatsapp.module';
|
||||
import { RedisCache } from '../../db/redis.client';
|
||||
import { execSync } from 'child_process';
|
||||
import { dbserver } from '../../db/db.connect';
|
||||
import mongoose from 'mongoose';
|
||||
import {
|
||||
AuthModel,
|
||||
ChatwootModel,
|
||||
ContactModel,
|
||||
MessageModel,
|
||||
MessageUpModel,
|
||||
WebhookModel,
|
||||
} from '../models';
|
||||
|
||||
export class WAMonitoringService {
|
||||
constructor(
|
||||
@ -45,6 +55,8 @@ export class WAMonitoringService {
|
||||
|
||||
private dbInstance: Db;
|
||||
|
||||
private dbStore = dbserver;
|
||||
|
||||
private readonly logger = new Logger(WAMonitoringService.name);
|
||||
public readonly waInstances: Record<string, WAStartupService> = {};
|
||||
|
||||
@ -218,11 +230,8 @@ export class WAMonitoringService {
|
||||
}
|
||||
|
||||
public async cleaningStoreFiles(instanceName: string) {
|
||||
this.logger.verbose('cleaning store files instance: ' + instanceName);
|
||||
|
||||
if (!this.db.ENABLED) {
|
||||
const instance = this.waInstances[instanceName];
|
||||
|
||||
this.logger.verbose('cleaning store files instance: ' + instanceName);
|
||||
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
|
||||
|
||||
execSync(`rm -rf ${join(STORE_DIR, 'chats', instanceName)}`);
|
||||
@ -233,7 +242,21 @@ export class WAMonitoringService {
|
||||
execSync(`rm -rf ${join(STORE_DIR, 'auth', 'apikey', instanceName + '.json')}`);
|
||||
execSync(`rm -rf ${join(STORE_DIR, 'webhook', instanceName + '.json')}`);
|
||||
execSync(`rm -rf ${join(STORE_DIR, 'chatwoot', instanceName + '*')}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.verbose('cleaning store database instance: ' + instanceName);
|
||||
|
||||
await AuthModel.deleteMany({ owner: instanceName });
|
||||
await ContactModel.deleteMany({ owner: instanceName });
|
||||
await MessageModel.deleteMany({ owner: instanceName });
|
||||
await MessageUpModel.deleteMany({ owner: instanceName });
|
||||
await AuthModel.deleteMany({ _id: instanceName });
|
||||
await WebhookModel.deleteMany({ _id: instanceName });
|
||||
await ChatwootModel.deleteMany({ _id: instanceName });
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public async loadInstance() {
|
||||
|
Loading…
Reference in New Issue
Block a user