fix: include instance Id field in the instance configuration

This commit is contained in:
Davidson Gomes 2023-12-17 09:37:18 -03:00
parent 2d6a29664a
commit da796347c4
2 changed files with 6 additions and 3 deletions

View File

@ -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<string> {
public async findInstanceNameById(instanceId: string): Promise<string | null> {
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;
}
}
}

View File

@ -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`);
}