fix: adjusts in messageType

This commit is contained in:
Davidson Gomes 2024-02-18 08:43:40 -03:00
parent 7e65cb1d19
commit 1595da789d
2 changed files with 28 additions and 4 deletions

View File

@ -335,7 +335,7 @@ export class WAMonitoringService {
const integration = await this.repository.integration.find(name);
let instance: BaileysStartupService | BusinessStartupService;
if (integration.integration === Integration.WHATSAPP_BUSINESS) {
if (integration && integration.integration === Integration.WHATSAPP_BUSINESS) {
instance = new BusinessStartupService(
this.configService,
this.eventEmitter,

View File

@ -266,6 +266,30 @@ export class BusinessStartupService extends WAStartupService {
return content;
}
private async renderMessageType(type: string) {
let messageType: string;
switch (type) {
case 'image':
messageType = 'imageMessage';
break;
case 'video':
messageType = 'videoMessage';
break;
case 'audio':
messageType = 'audioMessage';
break;
case 'document':
messageType = 'documentMessage';
break;
default:
messageType = 'imageMessage';
break;
}
return messageType;
}
protected async messageHandle(received: any, database: Database, settings: SettingsRaw) {
try {
let messageRaw: MessageRaw;
@ -293,7 +317,7 @@ export class BusinessStartupService extends WAStartupService {
...this.messageMediaJson(received),
base64: buffer ? buffer.toString('base64') : undefined,
},
messageType: received.messages[0].type,
messageType: await this.renderMessageType(received.messages[0].type),
messageTimestamp: received.messages[0].timestamp as number,
owner: this.instance.name,
// source: getDevice(received.key.id),
@ -305,7 +329,7 @@ export class BusinessStartupService extends WAStartupService {
message: {
...this.messageInteractiveJson(received),
},
messageType: 'text',
messageType: 'conversation',
messageTimestamp: received.messages[0].timestamp as number,
owner: this.instance.name,
// source: getDevice(received.key.id),
@ -317,7 +341,7 @@ export class BusinessStartupService extends WAStartupService {
message: {
...this.messageContactsJson(received),
},
messageType: 'text',
messageType: 'conversation',
messageTimestamp: received.messages[0].timestamp as number,
owner: this.instance.name,
// source: getDevice(received.key.id),