Conversation
WalkthroughAdds a runtime dependency Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant Test as test/index.js
participant FF as FFmpeg (fluent-ffmpeg)
participant Sender as sender.layer
Dev->>Test: start()
Test->>FF: transcode test.mp3 → test.ogg (libopus, mono, 16kHz)
FF-->>Test: test.ogg (on end)
Test->>Sender: sendVoice('test.ogg')
Sender-->>Test: resolve/reject
sequenceDiagram
autonumber
participant Client as Caller
participant Sender as sender.layer
participant Net as Downloader
Client->>Sender: sendVoice(src)
alt src is URL/Path
Sender->>Net: download/read as base64
Net-->>Sender: base64 + MIME (audio/ogg|audio/mpeg|audio/mp3)
end
alt MIME in {audio/ogg, audio/mpeg, audio/mp3}
Sender-->>Client: proceed with PTT/sendVoice flow
else Unsupported MIME
Sender-->>Client: reject or alternate handling
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/api/layers/sender.layer.ts (2)
902-906: Update error message to reflect OGG support.The error message still states "Use the MP3 format" but the code now accepts both MP3 and OGG formats.
Apply this diff to update the error message:
} else { obj = { erro: true, to: to, - text: 'Use the MP3 format to be able to send an audio!' + text: 'Unsupported audio format. Use MP3 or OGG format to send audio.' }; return reject(obj); }
811-834: Inconsistency: sendVoiceBase64 lacks audio/ogg support.The
sendVoicefunction now supportsaudio/ogg, butsendVoiceBase64(lines 811-834) only checks foraudio/mpegandaudio/mp3. This creates an API inconsistency where users can send OGG files viasendVoicebut not viasendVoiceBase64.Additionally, line 812 has a pre-existing logic bug: the condition
!mimeType || mimeType.includes('audio/mpeg') || mimeType.includes('audio/mp3')will pass if!mimeTypeis true, allowing invalid base64 through the MIME check.Apply this diff to add OGG support and fix the logic bug:
public async sendVoiceBase64(to: string, base64: string, passId?: any) { return new Promise(async (resolve, reject) => { const mimeType: any = base64MimeType(base64); if (!mimeType) { obj = { erro: true, to: to, text: 'Invalid base64!' }; return reject(obj); } if ( - !mimeType || - mimeType.includes('audio/mpeg') || - mimeType.includes('audio/mp3') + mimeType.includes('audio/mpeg') || + mimeType.includes('audio/mp3') || + mimeType.includes('audio/ogg') ) { const result = await this.page.evaluate( ({ to, base64, passId }) => { return WAPI.sendPtt(base64, to, passId); }, { to, base64, passId } ); if (result['erro'] == true) { reject(result); } else { resolve(result); } } else { obj = { erro: true, to: to, - text: 'Use the MP3 format to be able to send an audio!' + text: 'Unsupported audio format. Use MP3 or OGG format to send audio.' }; return reject(obj); } }); }
🧹 Nitpick comments (1)
test/index.js (1)
26-27: Hard-coded file paths reduce test flexibility.The test uses hard-coded paths (
test.mp3,test.ogg) which may not exist or may vary across environments.Consider making these configurable or checking file existence:
+ const inputPath = process.env.TEST_AUDIO_INPUT || 'test.mp3'; + const out = process.env.TEST_AUDIO_OUTPUT || 'test.ogg'; - let inputPath = 'test.mp3'; - let out = 'test.ogg'; + + // Verify input file exists before processing + const fs = await import('fs'); + if (!fs.existsSync(inputPath)) { + console.error(`Input file not found: ${inputPath}`); + return; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
package.json(1 hunks)src/api/layers/sender.layer.ts(2 hunks)test/index.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
test/index.js
📄 CodeRabbit inference engine (CLAUDE.md)
Use test/index.js as the main test script; tests are basic scripts without a formal framework
Files:
test/index.js
src/api/layers/*.layer.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Keep functionality layers in src/api/layers using the *.layer.ts naming (e.g., sender.layer.ts, listener.layer.ts, group.layer.ts, profile.layer.ts, controls.layer.ts, retriever.layer.ts)
Files:
src/api/layers/sender.layer.ts
🔇 Additional comments (1)
test/index.js (1)
43-43: Placeholder user ID in test.The user ID
'000000000000@c.us'appears to be a placeholder and will fail to deliver the message.Confirm whether this is intentional for local testing or if it should be replaced with a configurable recipient. If this is intended for CI/CD testing, consider skipping the actual send operation or using a mock.
Fixes # .
Changes proposed in this pull request
Whatsapp on android has voice message playback problems unless the message is sent via ogg format. This PR updates venom to allow ogg files, which can be created like this:
Summary by CodeRabbit