diff --git a/src/whatsapp/repository/auth.repository.ts b/src/whatsapp/repository/auth.repository.ts index 47fc579e..7aa1a427 100644 --- a/src/whatsapp/repository/auth.repository.ts +++ b/src/whatsapp/repository/auth.repository.ts @@ -5,7 +5,6 @@ import { Auth, ConfigService } from '../../config/env.config'; import { Logger } from '../../config/logger.config'; import { AUTH_DIR } from '../../config/path.config'; import { IInsert, Repository } from '../abstract/abstract.repository'; -import { InstanceDto } from '../dto/instance.dto'; import { AuthRaw, IAuthModel } from '../models'; export class AuthRepository extends Repository { @@ -65,7 +64,7 @@ export class AuthRepository extends Repository { } } - public async findInstanceNameById(instanceId: string): Promise { + public async findInstanceNameById(instanceId: string): Promise { try { this.logger.verbose('finding auth by instanceId'); if (this.dbSettings.ENABLED) { @@ -77,7 +76,7 @@ export class AuthRepository extends Repository { this.logger.verbose('finding auth in store is not supported'); } catch (error) { - return ''; + return null; } } } diff --git a/src/whatsapp/services/monitor.service.ts b/src/whatsapp/services/monitor.service.ts index 78c83c85..b449f693 100644 --- a/src/whatsapp/services/monitor.service.ts +++ b/src/whatsapp/services/monitor.service.ts @@ -162,6 +162,10 @@ export class WAMonitoringService { public async instanceInfoById(instanceId?: string) { this.logger.verbose('get instance info'); const instanceName = await this.repository.auth.findInstanceNameById(instanceId); + if (!instanceName) { + throw new NotFoundException(`Instance "${instanceId}" not found`); + } + if (instanceName && !this.waInstances[instanceName]) { throw new NotFoundException(`Instance "${instanceName}" not found`); }