Skip to content

Commit deb408c

Browse files
K3P1ELclaude
andcommitted
fix(baileys): preserve protobuf Long prototypes in patchMessageBeforeSending
Replaces JSON.parse(JSON.stringify(message)) clones with in-place mutation. The clone destroyed protobuf Long prototypes causing "TypeError: this.isZero is not a function" when sending lists/buttons in v2.3.6. Backport of upstream PR EvolutionAPI#2461 (EvolutionAPI#2461). Unblocks /message/sendList endpoint for our SaaS WhatsApp button workflows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5b73721 commit deb408c

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,17 +658,16 @@ export class BaileysStartupService extends ChannelStartupService {
658658
userDevicesCache: this.userDevicesCache,
659659
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
660660
patchMessageBeforeSending(message) {
661+
// Fix PR #2461: NO usar JSON.parse(JSON.stringify) porque destruye los Long de protobuf
662+
// y produce error "this.isZero is not a function" al enviar listas/botones.
663+
// Mutamos directamente sin clonar.
661664
if (
662665
message.deviceSentMessage?.message?.listMessage?.listType === proto.Message.ListMessage.ListType.PRODUCT_LIST
663666
) {
664-
message = JSON.parse(JSON.stringify(message));
665-
666667
message.deviceSentMessage.message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
667668
}
668669

669670
if (message.listMessage?.listType == proto.Message.ListMessage.ListType.PRODUCT_LIST) {
670-
message = JSON.parse(JSON.stringify(message));
671-
672671
message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
673672
}
674673

0 commit comments

Comments
 (0)