mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
fix: adjusts in messageType
This commit is contained in:
parent
7e65cb1d19
commit
1595da789d
@ -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,
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user