Skip to content

Commit e27818e

Browse files
committed
adjusts in integration
1 parent 5336168 commit e27818e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/api/services/integration.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export class IntegrationService {
2222
const result = await this.waMonitor.waInstances[instance.instanceName].findIntegration();
2323

2424
if (Object.keys(result).length === 0) {
25-
throw new Error('Integration not found');
25+
this.create(instance, { integration: 'WHATSAPP-BAILEYS', number: '', token: '' });
26+
return { integration: 'WHATSAPP-BAILEYS', number: '', token: '' };
2627
}
2728

2829
return result;

src/api/services/whatsapp.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ export class WAStartupService {
136136

137137
public async findIntegration() {
138138
this.logger.verbose('Finding integration');
139-
const data = await this.repository.integration.find(this.instanceName);
139+
let data: any;
140+
141+
data = await this.repository.integration.find(this.instanceName);
140142

141143
if (!data) {
142-
this.logger.verbose('Integration not found');
143-
throw new NotFoundException('Integration not found');
144+
this.repository.integration.create({ integration: 'WHATSAPP-BAILEYS', number: '', token: '' }, this.instanceName);
145+
data = { integration: 'WHATSAPP-BAILEYS', number: '', token: '' };
144146
}
145147

146148
this.logger.verbose(`Integration: ${data.integration}`);

0 commit comments

Comments
 (0)