Skip to content

Commit 6a7983a

Browse files
committed
feat: Add Baileys patch to prevent waveform overwrite
- Install patch-package as dev dependency - Create patch for baileys@7.0.0-rc.6 to check if waveform already exists before generating - Add postinstall script to apply patches automatically - This fixes the issue where Baileys was overwriting manually generated waveforms
1 parent a89398a commit 6a7983a

File tree

3 files changed

+276
-0
lines changed

3 files changed

+276
-0
lines changed

package-lock.json

Lines changed: 261 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"db:studio": "node runWithProvider.js \"npx prisma studio --schema ./prisma/DATABASE_PROVIDER-schema.prisma\"",
2121
"db:migrate:dev": "node runWithProvider.js \"rm -rf ./prisma/migrations && cp -r ./prisma/DATABASE_PROVIDER-migrations ./prisma/migrations && npx prisma migrate dev --schema ./prisma/DATABASE_PROVIDER-schema.prisma && cp -r ./prisma/migrations/* ./prisma/DATABASE_PROVIDER-migrations\"",
2222
"db:migrate:dev:win": "node runWithProvider.js \"xcopy /E /I prisma\\DATABASE_PROVIDER-migrations prisma\\migrations && npx prisma migrate dev --schema prisma\\DATABASE_PROVIDER-schema.prisma\"",
23+
"postinstall": "patch-package",
2324
"prepare": "husky"
2425
},
2526
"repository": {
@@ -147,6 +148,7 @@
147148
"eslint-plugin-simple-import-sort": "^12.1.1",
148149
"husky": "^9.1.7",
149150
"lint-staged": "^16.1.6",
151+
"patch-package": "^8.0.1",
150152
"prettier": "^3.4.2",
151153
"tsconfig-paths": "^4.2.0",
152154
"tsx": "^4.20.5",

patches/baileys+7.0.0-rc.6.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/baileys/lib/Utils/messages.js b/node_modules/baileys/lib/Utils/messages.js
2+
index 17b05b8..782efb4 100644
3+
--- a/node_modules/baileys/lib/Utils/messages.js
4+
+++ b/node_modules/baileys/lib/Utils/messages.js
5+
@@ -132,7 +132,7 @@ export const prepareWAMessageMedia = async (message, options) => {
6+
}
7+
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
8+
const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') && typeof uploadData['jpegThumbnail'] === 'undefined';
9+
- const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true;
10+
+ const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined';
11+
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
12+
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
13+
const { mediaKey, encFilePath, originalFilePath, fileEncSha256, fileSha256, fileLength } = await encryptedStream(uploadData.media, options.mediaTypeOverride || mediaType, {

0 commit comments

Comments
 (0)