Skip to content

Commit da79634

Browse files
committed
fix: include instance Id field in the instance configuration
1 parent 2d6a296 commit da79634

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/whatsapp/repository/auth.repository.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Auth, ConfigService } from '../../config/env.config';
55
import { Logger } from '../../config/logger.config';
66
import { AUTH_DIR } from '../../config/path.config';
77
import { IInsert, Repository } from '../abstract/abstract.repository';
8-
import { InstanceDto } from '../dto/instance.dto';
98
import { AuthRaw, IAuthModel } from '../models';
109

1110
export class AuthRepository extends Repository {
@@ -65,7 +64,7 @@ export class AuthRepository extends Repository {
6564
}
6665
}
6766

68-
public async findInstanceNameById(instanceId: string): Promise<string> {
67+
public async findInstanceNameById(instanceId: string): Promise<string | null> {
6968
try {
7069
this.logger.verbose('finding auth by instanceId');
7170
if (this.dbSettings.ENABLED) {
@@ -77,7 +76,7 @@ export class AuthRepository extends Repository {
7776

7877
this.logger.verbose('finding auth in store is not supported');
7978
} catch (error) {
80-
return '';
79+
return null;
8180
}
8281
}
8382
}

src/whatsapp/services/monitor.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ export class WAMonitoringService {
162162
public async instanceInfoById(instanceId?: string) {
163163
this.logger.verbose('get instance info');
164164
const instanceName = await this.repository.auth.findInstanceNameById(instanceId);
165+
if (!instanceName) {
166+
throw new NotFoundException(`Instance "${instanceId}" not found`);
167+
}
168+
165169
if (instanceName && !this.waInstances[instanceName]) {
166170
throw new NotFoundException(`Instance "${instanceName}" not found`);
167171
}

0 commit comments

Comments
 (0)