Skip to content

Commit

Permalink
Adjust to repository from session worker
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed Jun 1, 2024
1 parent 9354af3 commit 5b2a0fd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/controllers/instance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ export class InstanceController {
this.logger.verbose('deleting instance: ' + instanceName);

try {
this.waMonitor.waInstances[instanceName].sendDataWebhook(Events.INSTANCE_DELETE, {
this.waMonitor.waInstances[instanceName]?.sendDataWebhook(Events.INSTANCE_DELETE, {
instanceName,
instanceId: (await this.repository.auth.find(instanceName))?.instanceId,
});
Expand Down
4 changes: 2 additions & 2 deletions src/api/services/channels/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1478,15 +1478,15 @@ export class BaileysStartupService extends ChannelStartupService {
this.logger.verbose('Sending data to webhook in event LABELS_ASSOCIATION');

// Atualiza labels nos chats
if (database.SAVE_DATA.CHATS) {
if (database.ENABLED && database.SAVE_DATA.CHATS) {
const chats = await this.repository.chat.find({
where: {
owner: this.instance.name,
},
});
const chat = chats.find((c) => c.id === data.association.chatId);
if (chat) {
let labels = [...chat?.labels];
let labels = [...chat.labels];
if (data.type === 'remove') {
labels = labels.filter((label) => label !== data.association.labelId);
} else if (data.type === 'add') {
Expand Down
6 changes: 2 additions & 4 deletions src/api/services/monitor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,17 @@ export class WAMonitoringService {
this.logger.verbose('cleaning up instance in files: ' + instanceName);
if (this.providerSession?.ENABLED) {
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) {
if (!this.db.ENABLED) {
this.logger.verbose('cleaning store files instance: ' + instanceName);
if (this.providerSession?.ENABLED) {
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, 'contacts', instanceName)}`);
Expand Down

0 comments on commit 5b2a0fd

Please sign in to comment.