diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f1a3414..0a62e4f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ * Fixed require fileName for document only in base64 for send media message * Bug fix when sending mobile message change contact name to number in chatwoot * Bug fix when connecting whatsapp does not send confirmation message +* Fixed quoted message with id or message directly ### Integrations diff --git a/src/validate/validate.schema.ts b/src/validate/validate.schema.ts index 77e05f19..2b9ce19a 100644 --- a/src/validate/validate.schema.ts +++ b/src/validate/validate.schema.ts @@ -82,8 +82,8 @@ const quotedOptionsSchema: JSONSchema7 = { remoteJid: { type: 'string' }, fromMe: { type: 'boolean', enum: [true, false] }, }, - required: ['id', 'remoteJid', 'fromMe'], - ...isNotEmpty('id', 'remoteJid'), + required: ['id'], + ...isNotEmpty('id'), }, message: { type: 'object' }, }, diff --git a/src/whatsapp/guards/instance.guard.ts b/src/whatsapp/guards/instance.guard.ts index 9e7a0e4b..1e79ff1d 100644 --- a/src/whatsapp/guards/instance.guard.ts +++ b/src/whatsapp/guards/instance.guard.ts @@ -11,7 +11,6 @@ import { import { InstanceDto } from '../dto/instance.dto'; import { cache, waMonitor } from '../whatsapp.module'; import { Database, Redis, configService } from '../../config/env.config'; -import { RedisCache } from '../../db/redis.client'; async function getInstance(instanceName: string) { const db = configService.get('DATABASE'); diff --git a/src/whatsapp/services/chatwoot.service.ts b/src/whatsapp/services/chatwoot.service.ts index ba0c5d0b..49fd4e7d 100644 --- a/src/whatsapp/services/chatwoot.service.ts +++ b/src/whatsapp/services/chatwoot.service.ts @@ -936,7 +936,7 @@ export class ChatwootService { const command = messageReceived.replace('/', ''); - if (command === 'init') { + if (command === 'init' || command === 'iniciar') { this.logger.verbose('command init found'); const state = waInstance?.connectionStatus?.state; @@ -977,7 +977,7 @@ export class ChatwootService { } } - if (command === 'disconnect') { + if (command === 'disconnect' || command === 'desconectar') { this.logger.verbose('command disconnect found'); const msgLogout = `🚨 Disconnecting Whatsapp from inbox *${body.inbox.name}*: `; diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 18547998..ba167c53 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -1480,7 +1480,17 @@ export class WAStartupService { let quoted: WAMessage; if (options?.quoted) { - quoted = options?.quoted; + const m = options?.quoted; + + const msg = m?.message + ? m + : ((await this.getMessage(m.key, true)) as proto.IWebMessageInfo); + + if (!msg) { + throw 'Message not found'; + } + + quoted = msg; this.logger.verbose('Quoted message'); } @@ -1776,8 +1786,10 @@ export class WAStartupService { public async statusMessage(data: SendStatusDto) { this.logger.verbose('Sending status message'); + const status = await this.formatStatusMessage(data.statusMessage); + return await this.sendMessageWithTyping('status@broadcast', { - status: await this.formatStatusMessage(data.statusMessage), + status, }); }