Adjust to repository from session worker

This commit is contained in:
Davidson Gomes 2024-06-01 19:29:37 -03:00
parent 9354af3bc7
commit 5b2a0fdcb1
3 changed files with 5 additions and 7 deletions

View File

@ -753,7 +753,7 @@ export class InstanceController {
this.logger.verbose('deleting instance: ' + instanceName); this.logger.verbose('deleting instance: ' + instanceName);
try { try {
this.waMonitor.waInstances[instanceName].sendDataWebhook(Events.INSTANCE_DELETE, { this.waMonitor.waInstances[instanceName]?.sendDataWebhook(Events.INSTANCE_DELETE, {
instanceName, instanceName,
instanceId: (await this.repository.auth.find(instanceName))?.instanceId, instanceId: (await this.repository.auth.find(instanceName))?.instanceId,
}); });

View File

@ -1478,7 +1478,7 @@ export class BaileysStartupService extends ChannelStartupService {
this.logger.verbose('Sending data to webhook in event LABELS_ASSOCIATION'); this.logger.verbose('Sending data to webhook in event LABELS_ASSOCIATION');
// Atualiza labels nos chats // Atualiza labels nos chats
if (database.SAVE_DATA.CHATS) { if (database.ENABLED && database.SAVE_DATA.CHATS) {
const chats = await this.repository.chat.find({ const chats = await this.repository.chat.find({
where: { where: {
owner: this.instance.name, owner: this.instance.name,
@ -1486,7 +1486,7 @@ export class BaileysStartupService extends ChannelStartupService {
}); });
const chat = chats.find((c) => c.id === data.association.chatId); const chat = chats.find((c) => c.id === data.association.chatId);
if (chat) { if (chat) {
let labels = [...chat?.labels]; let labels = [...chat.labels];
if (data.type === 'remove') { if (data.type === 'remove') {
labels = labels.filter((label) => label !== data.association.labelId); labels = labels.filter((label) => label !== data.association.labelId);
} else if (data.type === 'add') { } else if (data.type === 'add') {

View File

@ -271,9 +271,8 @@ export class WAMonitoringService {
this.logger.verbose('cleaning up instance in files: ' + instanceName); this.logger.verbose('cleaning up instance in files: ' + instanceName);
if (this.providerSession?.ENABLED) { if (this.providerSession?.ENABLED) {
await this.providerFiles.removeSession(instanceName); await this.providerFiles.removeSession(instanceName);
} else {
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
} }
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
} }
public async cleaningStoreFiles(instanceName: string) { public async cleaningStoreFiles(instanceName: string) {
@ -281,9 +280,8 @@ export class WAMonitoringService {
this.logger.verbose('cleaning store files instance: ' + instanceName); this.logger.verbose('cleaning store files instance: ' + instanceName);
if (this.providerSession?.ENABLED) { if (this.providerSession?.ENABLED) {
await this.providerFiles.removeSession(instanceName); await this.providerFiles.removeSession(instanceName);
} else {
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
} }
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
execSync(`rm -rf ${join(STORE_DIR, 'chats', instanceName)}`); execSync(`rm -rf ${join(STORE_DIR, 'chats', instanceName)}`);
execSync(`rm -rf ${join(STORE_DIR, 'contacts', instanceName)}`); execSync(`rm -rf ${join(STORE_DIR, 'contacts', instanceName)}`);