diff --git a/CHANGELOG.md b/CHANGELOG.md index 3449ad1ba..936e5ac8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Widget Works Modification -* [WIDGET-WORKS] Silence "Parent message not found" warnings during history sync to prevent CPU overload and subsequent 401 disconnects. +* [WIDGET-WORKS] Patch Baileys to filter sender's own devices from senderKeyJids in LID group messages (fixes "not-acceptable" error preventing group message sends). * [WIDGET-WORKS] Fix `PrismaClientValidationError` in `messages.update` (missing `Message` relation) by guarding `messageUpdate.create` calls. * [WIDGET-WORKS] Guard `messages.update` cache cleanup with a derived key and optional `MESSAGE_UPDATE_CACHE_DELETE_DISABLED` flag to prevent cache.delete crash-loops. * [WIDGET-WORKS] Save messages before Chatwoot sync in `/message/sendText` to avoid missing `chatwootMessageId` and log async sync failures. diff --git a/Dockerfile b/Dockerfile index 2f30eea09..28e04b249 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM node:20-alpine AS builder RUN apk update && \ - apk add --no-cache git ffmpeg wget curl bash openssl + apk add --no-cache git ffmpeg wget curl bash openssl patch LABEL version="2.3.2" description="Api to control whatsapp features through http requests." LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" @@ -15,6 +15,10 @@ COPY ./tsup.config.ts ./ RUN npm ci --silent +# [WIDGET-WORKS] Apply Baileys patch for LID group send fix +COPY ./patches ./patches +RUN patch -p1 < patches/baileys+6.7.19+lid-group-send.patch + COPY ./src ./src COPY ./public ./public COPY ./prisma ./prisma diff --git a/patches/baileys+6.7.19+lid-group-send.patch b/patches/baileys+6.7.19+lid-group-send.patch new file mode 100644 index 000000000..e3e29d7f1 --- /dev/null +++ b/patches/baileys+6.7.19+lid-group-send.patch @@ -0,0 +1,22 @@ +diff --git a/node_modules/baileys/lib/Socket/messages-send.js b/node_modules/baileys/lib/Socket/messages-send.js +index 1234567..abcdefg 100644 +--- a/node_modules/baileys/lib/Socket/messages-send.js ++++ b/node_modules/baileys/lib/Socket/messages-send.js +@@ -360,8 +360,14 @@ export const makeMessagesSocket = (config) => { + meId + }); + const senderKeyJids = []; +- // ensure a connection is established with every device ++ // [WIDGET-WORKS] Filter sender's own devices from senderKeyJids (LID group send fix) ++ // Same pattern as non-group path (line ~396) - fixes "not-acceptable" error ++ const { user: meUser } = jidDecode(meId); ++ const meLid = authState.creds?.me?.lid?.split(':')[0]?.split('@')[0]; ++ // ensure a connection is established with every device + for (const { user, device } of devices) { ++ // [WIDGET-WORKS] Skip sender's own devices ++ if (user === meUser || user === meLid) { ++ continue; ++ } + const jid = jidEncode(user, groupData?.addressingMode === 'lid' ? 'lid' : 's.whatsapp.net', device); + if (!senderKeyMap[jid] || !!participant) { + senderKeyJids.push(jid);