Remove instance from redis even if using database

This commit is contained in:
Judson Cairo 2024-08-12 21:03:51 -03:00
parent dbb6ea9147
commit 041b3c5e1f

View File

@ -120,6 +120,7 @@ export class WAMonitoringService {
}
public async cleaningUp(instanceName: string) {
let instanceDbId: string;
if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
const instance = await this.prismaRepository.instance.update({
where: { name: instanceName },
@ -130,13 +131,16 @@ export class WAMonitoringService {
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
instanceDbId = instance.id;
await this.prismaRepository.session.deleteMany({ where: { sessionId: instance.id } });
return;
}
if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
console.log({ instanceName, instanceDbId });
await this.cache.delete(instanceName);
return;
if (instanceDbId) {
await this.cache.delete(instanceDbId);
}
}
if (this.providerSession?.ENABLED) {