mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-25 01:48:39 -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);
|
const integration = await this.repository.integration.find(name);
|
||||||
|
|
||||||
let instance: BaileysStartupService | BusinessStartupService;
|
let instance: BaileysStartupService | BusinessStartupService;
|
||||||
if (integration.integration === Integration.WHATSAPP_BUSINESS) {
|
if (integration && integration.integration === Integration.WHATSAPP_BUSINESS) {
|
||||||
instance = new BusinessStartupService(
|
instance = new BusinessStartupService(
|
||||||
this.configService,
|
this.configService,
|
||||||
this.eventEmitter,
|
this.eventEmitter,
|
||||||
|
@ -266,6 +266,30 @@ export class BusinessStartupService extends WAStartupService {
|
|||||||
return content;
|
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) {
|
protected async messageHandle(received: any, database: Database, settings: SettingsRaw) {
|
||||||
try {
|
try {
|
||||||
let messageRaw: MessageRaw;
|
let messageRaw: MessageRaw;
|
||||||
@ -293,7 +317,7 @@ export class BusinessStartupService extends WAStartupService {
|
|||||||
...this.messageMediaJson(received),
|
...this.messageMediaJson(received),
|
||||||
base64: buffer ? buffer.toString('base64') : undefined,
|
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,
|
messageTimestamp: received.messages[0].timestamp as number,
|
||||||
owner: this.instance.name,
|
owner: this.instance.name,
|
||||||
// source: getDevice(received.key.id),
|
// source: getDevice(received.key.id),
|
||||||
@ -305,7 +329,7 @@ export class BusinessStartupService extends WAStartupService {
|
|||||||
message: {
|
message: {
|
||||||
...this.messageInteractiveJson(received),
|
...this.messageInteractiveJson(received),
|
||||||
},
|
},
|
||||||
messageType: 'text',
|
messageType: 'conversation',
|
||||||
messageTimestamp: received.messages[0].timestamp as number,
|
messageTimestamp: received.messages[0].timestamp as number,
|
||||||
owner: this.instance.name,
|
owner: this.instance.name,
|
||||||
// source: getDevice(received.key.id),
|
// source: getDevice(received.key.id),
|
||||||
@ -317,7 +341,7 @@ export class BusinessStartupService extends WAStartupService {
|
|||||||
message: {
|
message: {
|
||||||
...this.messageContactsJson(received),
|
...this.messageContactsJson(received),
|
||||||
},
|
},
|
||||||
messageType: 'text',
|
messageType: 'conversation',
|
||||||
messageTimestamp: received.messages[0].timestamp as number,
|
messageTimestamp: received.messages[0].timestamp as number,
|
||||||
owner: this.instance.name,
|
owner: this.instance.name,
|
||||||
// source: getDevice(received.key.id),
|
// source: getDevice(received.key.id),
|
||||||
|
Loading…
Reference in New Issue
Block a user