Skip to content

Commit 8e5093c

Browse files
authored
fix: respect caller-provided waveform for PTT audio messages (#2443)
* fix: respect caller-provided waveform for PTT audio messages When a caller explicitly passes a `waveform` in the message options, Baileys was unconditionally overwriting it with the result of `getAudioWaveform()`. If `audio-decode` is not installed (it is an optional peer dependency), `getAudioWaveform()` silently returns `undefined`, discarding the caller's value and causing WhatsApp to render a flat-line waveform. Fix: only invoke `getAudioWaveform()` when no waveform has been provided by the caller (`!uploadData.waveform`). * refactor: move waveform guard to flag definition, use typeof check * fix: lint
1 parent 802d5f6 commit 8e5093c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Utils/messages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ export const prepareWAMessageMedia = async (
223223
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined'
224224
const requiresThumbnailComputation =
225225
(mediaType === 'image' || mediaType === 'video') && typeof uploadData['jpegThumbnail'] === 'undefined'
226-
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true
226+
const requiresWaveformProcessing =
227+
mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined'
227228
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true
228229
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation
229230
const { mediaKey, encFilePath, originalFilePath, fileEncSha256, fileSha256, fileLength } = await encryptedStream(

0 commit comments

Comments
 (0)