Skip to content

Commit e2c67d7

Browse files
committed
fix: integration
1 parent 703bc31 commit e2c67d7

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/whatsapp/controllers/instance.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export class InstanceController {
105105
this.cache,
106106
this.chatwootCache,
107107
);
108-
await this.waMonitor.saveInstance({ integration, instanceName, token, number });
109108
} else {
110109
instance = new BaileysStartupService(
111110
this.configService,
@@ -116,6 +115,8 @@ export class InstanceController {
116115
);
117116
}
118117

118+
await this.waMonitor.saveInstance({ integration, instanceName, token, number });
119+
119120
instance.instanceName = instanceName;
120121

121122
const instanceId = v4();

src/whatsapp/services/monitor.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ export class WAMonitoringService {
347347
this.cache,
348348
this.chatwootCache,
349349
);
350+
351+
instance.instanceName = name;
350352
} else {
351353
instance = new BaileysStartupService(
352354
this.configService,
@@ -355,8 +357,14 @@ export class WAMonitoringService {
355357
this.cache,
356358
this.chatwootCache,
357359
);
360+
361+
instance.instanceName = name;
362+
363+
if (!integration) {
364+
await instance.setIntegration({ integration: Integration.WHATSAPP_BAILEYS });
365+
}
358366
}
359-
instance.instanceName = name;
367+
360368
this.logger.verbose('Instance loaded: ' + name);
361369
await instance.connectToWhatsapp();
362370
this.logger.verbose('connectToWhatsapp: ' + name);

src/whatsapp/services/whatsapp.baileys.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,13 +2020,22 @@ export class BaileysStartupService extends WAStartupService {
20202020
if (mediaMessage.mimetype) {
20212021
mimetype = mediaMessage.mimetype;
20222022
} else {
2023-
if (isURL(mediaMessage.media)) {
2023+
mimetype = getMIMEType(mediaMessage.fileName);
2024+
2025+
if (!mimetype && isURL(mediaMessage.media)) {
20242026
const response = await axios.get(mediaMessage.media, { responseType: 'arraybuffer' });
20252027

20262028
mimetype = response.headers['content-type'];
2027-
} else {
2028-
mimetype = getMIMEType(mediaMessage.fileName);
20292029
}
2030+
// if (isURL(mediaMessage.media)) {
2031+
// const response = await axios.get(mediaMessage.media, { responseType: 'arraybuffer' });
2032+
2033+
// mimetype = response.headers['content-type'];
2034+
// console.log('mediaMessage.mimetype2', mimetype);
2035+
// } else {
2036+
// mimetype = getMIMEType(mediaMessage.fileName);
2037+
// console.log('mediaMessage.mimetype3', mimetype);
2038+
// }
20302039
}
20312040

20322041
this.logger.verbose('Mimetype: ' + mimetype);

0 commit comments

Comments
 (0)