feat: convert outgoing audio to MP3 inside send_media case to bypass getAudioDuration
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
PODS:
|
PODS:
|
||||||
|
- audioplayers_darwin (0.0.1):
|
||||||
|
- Flutter
|
||||||
|
- FlutterMacOS
|
||||||
- Firebase/CoreOnly (10.25.0):
|
- Firebase/CoreOnly (10.25.0):
|
||||||
- FirebaseCore (= 10.25.0)
|
- FirebaseCore (= 10.25.0)
|
||||||
- Firebase/Messaging (10.25.0):
|
- Firebase/Messaging (10.25.0):
|
||||||
@@ -65,6 +68,8 @@ PODS:
|
|||||||
- GoogleUtilities/UserDefaults (7.13.3):
|
- GoogleUtilities/UserDefaults (7.13.3):
|
||||||
- GoogleUtilities/Logger
|
- GoogleUtilities/Logger
|
||||||
- GoogleUtilities/Privacy
|
- GoogleUtilities/Privacy
|
||||||
|
- image_picker_ios (0.0.1):
|
||||||
|
- Flutter
|
||||||
- nanopb (2.30910.0):
|
- nanopb (2.30910.0):
|
||||||
- nanopb/decode (= 2.30910.0)
|
- nanopb/decode (= 2.30910.0)
|
||||||
- nanopb/encode (= 2.30910.0)
|
- nanopb/encode (= 2.30910.0)
|
||||||
@@ -79,11 +84,13 @@ PODS:
|
|||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
|
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/darwin`)
|
||||||
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
||||||
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
- flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`)
|
- flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`)
|
||||||
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
|
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
|
||||||
|
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||||
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
|
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
|
||||||
|
|
||||||
@@ -100,6 +107,8 @@ SPEC REPOS:
|
|||||||
- PromisesObjC
|
- PromisesObjC
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
|
audioplayers_darwin:
|
||||||
|
:path: ".symlinks/plugins/audioplayers_darwin/darwin"
|
||||||
firebase_core:
|
firebase_core:
|
||||||
:path: ".symlinks/plugins/firebase_core/ios"
|
:path: ".symlinks/plugins/firebase_core/ios"
|
||||||
firebase_messaging:
|
firebase_messaging:
|
||||||
@@ -110,12 +119,15 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/flutter_contacts/ios"
|
:path: ".symlinks/plugins/flutter_contacts/ios"
|
||||||
flutter_local_notifications:
|
flutter_local_notifications:
|
||||||
:path: ".symlinks/plugins/flutter_local_notifications/ios"
|
:path: ".symlinks/plugins/flutter_local_notifications/ios"
|
||||||
|
image_picker_ios:
|
||||||
|
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||||
sqflite_darwin:
|
sqflite_darwin:
|
||||||
:path: ".symlinks/plugins/sqflite_darwin/darwin"
|
:path: ".symlinks/plugins/sqflite_darwin/darwin"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
|
audioplayers_darwin: 835ced6edd4c9fc8ebb0a7cc9e294a91d99917d5
|
||||||
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
|
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
|
||||||
firebase_core: 3b49a055ff54114cae400581c13671fe53936c36
|
firebase_core: 3b49a055ff54114cae400581c13671fe53936c36
|
||||||
firebase_messaging: 30fa3ec8cd0dc8a860b7817548911b97345a0875
|
firebase_messaging: 30fa3ec8cd0dc8a860b7817548911b97345a0875
|
||||||
@@ -128,6 +140,7 @@ SPEC CHECKSUMS:
|
|||||||
flutter_local_notifications: ad39620c743ea4c15127860f4b5641649a988100
|
flutter_local_notifications: ad39620c743ea4c15127860f4b5641649a988100
|
||||||
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
||||||
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
|
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
|
||||||
|
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
||||||
nanopb: 438bc412db1928dac798aa6fd75726007be04262
|
nanopb: 438bc412db1928dac798aa6fd75726007be04262
|
||||||
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
|
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
|
||||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||||
|
|||||||
@@ -459,10 +459,24 @@ async function handleMessage(ws, raw) {
|
|||||||
if (!clientReady) {
|
if (!clientReady) {
|
||||||
return respond({ type: 'error', message: 'WhatsApp is not ready' });
|
return respond({ type: 'error', message: 'WhatsApp is not ready' });
|
||||||
}
|
}
|
||||||
const { chatId, base64, mimetype, filename, caption } = payload;
|
let { chatId, base64, mimetype, filename, caption } = payload;
|
||||||
if (!chatId || !base64 || !mimetype) {
|
if (!chatId || !base64 || !mimetype) {
|
||||||
return respond({ type: 'error', message: 'chatId, base64, and mimetype are required' });
|
return respond({ type: 'error', message: 'chatId, base64, and mimetype are required' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it is an OGG audio file being sent, convert it to MP3 so the headless browser can decode it and calculate duration
|
||||||
|
if (mimetype && (mimetype.includes('audio/ogg') || mimetype.includes('ogg'))) {
|
||||||
|
try {
|
||||||
|
console.log(`[WS] Converting outgoing OGG audio to MP3 for Puppeteer compatibility...`);
|
||||||
|
const mp3Base64 = await convertOggToMp3(base64);
|
||||||
|
base64 = mp3Base64;
|
||||||
|
mimetype = 'audio/mp3';
|
||||||
|
filename = 'voice_note.mp3';
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[WS] Outgoing audio conversion failed (sending raw Ogg instead):`, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { MessageMedia } = require('whatsapp-web.js');
|
const { MessageMedia } = require('whatsapp-web.js');
|
||||||
const media = new MessageMedia(mimetype, base64, filename || 'file');
|
const media = new MessageMedia(mimetype, base64, filename || 'file');
|
||||||
|
|||||||
Reference in New Issue
Block a user