fix: pass quoted option in audioWhatsapp to support replies#2516
fix: pass quoted option in audioWhatsapp to support replies#2516octo-patch wants to merge 1 commit intoEvolutionAPI:mainfrom
Conversation
…olutionAPI#2485) The `audioWhatsapp` method was not forwarding `data.quoted` to `sendMessageWithTyping`, so audio messages sent with a `quoted` key were delivered as standalone messages instead of replies. Added `quoted: data?.quoted` to the options object in both `sendMessageWithTyping` call sites inside `audioWhatsapp` (the encoding path and the direct path), matching the pattern used by all other message-sending methods (textMessage, pollMessage, etc.). Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuidePasses the incoming Sequence diagram for sending WhatsApp audio reply with quoted optionsequenceDiagram
actor ApiClient
participant ApiServer
participant BaileysStartupService
participant WhatsAppGateway
ApiClient->>ApiServer: POST /message/sendWhatsAppAudio/{instance}
ApiServer->>BaileysStartupService: audioWhatsapp(number, audio, quoted, delay, isIntegration)
alt audioRequiresEncoding
BaileysStartupService->>BaileysStartupService: encodeToOggOpus(audio)
BaileysStartupService->>WhatsAppGateway: sendMessageWithTyping(number, audioContent, optionsWithQuoted, isIntegration)
else audioAlreadyEncoded
BaileysStartupService->>WhatsAppGateway: sendMessageWithTyping(number, audioContent, optionsWithQuoted, isIntegration)
end
Note over BaileysStartupService,WhatsAppGateway: optionsWithQuoted = { presence: recording, delay: delay, quoted: quoted }
WhatsAppGateway-->>ApiServer: messageSentAsReply
ApiServer-->>ApiClient: 200 OK
Class diagram for BaileysStartupService audioWhatsapp options including quotedclassDiagram
class BaileysStartupService {
+audioWhatsapp(number, audioBase64, quoted, delay, isIntegration) Promise~void~
+sendMessageWithTyping(number, content, options, isIntegration) Promise~AnyMessageContent~
}
class AudioOptions {
+presence string
+delay number
+quoted object
}
class AudioContent {
+audio any
+ptt boolean
+mimetype string
}
BaileysStartupService ..> AudioOptions : uses
BaileysStartupService ..> AudioContent : uses
AudioOptions : presence = recording
AudioOptions : delay = delay
AudioOptions : quoted = quoted
AudioContent : ptt = true
AudioContent : mimetype = audio/ogg, codecs=opus
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since multiple WhatsApp send methods now share the same
{ presence, delay, quoted }options pattern, consider extracting a small helper to build these options so future updates don’t accidentally omit fields in one code path (as happened here withaudioWhatsapp).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since multiple WhatsApp send methods now share the same `{ presence, delay, quoted }` options pattern, consider extracting a small helper to build these options so future updates don’t accidentally omit fields in one code path (as happened here with `audioWhatsapp`).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Thanks for the suggestion! You're right that the Happy to open a follow-up refactor PR if maintainers want one — just let me know. |
Fixes #2485
Problem
When sending audio with
sendWhatsAppAudioand aquotedkey in the payload:{ "number": "55489999999999", "audio": "<base64>", "quoted": { "key": { "id": "3EB0006934B47898977C8C" } } }The audio was delivered as a standalone message rather than as a reply. The
quotedfield was ignored.Root Cause
The
audioWhatsappmethod built the options object passed tosendMessageWithTypingas:The
quotedfield fromdatawas never forwarded, unlike every other message-sending method (textMessage,pollMessage,mediaMessage, etc.) which all passquoted: data?.quoted.Solution
Added
quoted: data?.quotedto the options in bothsendMessageWithTypingcall sites insideaudioWhatsapp(the encoding path and the direct path).Testing
Send a
POST /message/sendWhatsAppAudio/{instance}request with a validquoted.key.id. The audio message will now appear as a reply to the referenced message in WhatsApp.Summary by Sourcery
Bug Fixes: