Skip to content

Commit 1595da7

Browse files
committed
fix: adjusts in messageType
1 parent 7e65cb1 commit 1595da7

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/whatsapp/services/monitor.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export class WAMonitoringService {
335335
const integration = await this.repository.integration.find(name);
336336

337337
let instance: BaileysStartupService | BusinessStartupService;
338-
if (integration.integration === Integration.WHATSAPP_BUSINESS) {
338+
if (integration && integration.integration === Integration.WHATSAPP_BUSINESS) {
339339
instance = new BusinessStartupService(
340340
this.configService,
341341
this.eventEmitter,

src/whatsapp/services/whatsapp.business.service.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,30 @@ export class BusinessStartupService extends WAStartupService {
266266
return content;
267267
}
268268

269+
private async renderMessageType(type: string) {
270+
let messageType: string;
271+
272+
switch (type) {
273+
case 'image':
274+
messageType = 'imageMessage';
275+
break;
276+
case 'video':
277+
messageType = 'videoMessage';
278+
break;
279+
case 'audio':
280+
messageType = 'audioMessage';
281+
break;
282+
case 'document':
283+
messageType = 'documentMessage';
284+
break;
285+
default:
286+
messageType = 'imageMessage';
287+
break;
288+
}
289+
290+
return messageType;
291+
}
292+
269293
protected async messageHandle(received: any, database: Database, settings: SettingsRaw) {
270294
try {
271295
let messageRaw: MessageRaw;
@@ -293,7 +317,7 @@ export class BusinessStartupService extends WAStartupService {
293317
...this.messageMediaJson(received),
294318
base64: buffer ? buffer.toString('base64') : undefined,
295319
},
296-
messageType: received.messages[0].type,
320+
messageType: await this.renderMessageType(received.messages[0].type),
297321
messageTimestamp: received.messages[0].timestamp as number,
298322
owner: this.instance.name,
299323
// source: getDevice(received.key.id),
@@ -305,7 +329,7 @@ export class BusinessStartupService extends WAStartupService {
305329
message: {
306330
...this.messageInteractiveJson(received),
307331
},
308-
messageType: 'text',
332+
messageType: 'conversation',
309333
messageTimestamp: received.messages[0].timestamp as number,
310334
owner: this.instance.name,
311335
// source: getDevice(received.key.id),
@@ -317,7 +341,7 @@ export class BusinessStartupService extends WAStartupService {
317341
message: {
318342
...this.messageContactsJson(received),
319343
},
320-
messageType: 'text',
344+
messageType: 'conversation',
321345
messageTimestamp: received.messages[0].timestamp as number,
322346
owner: this.instance.name,
323347
// source: getDevice(received.key.id),

0 commit comments

Comments
 (0)