Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(message): backfill stored button replies to the text type
Yudhi Armyndharisdb182695fcb2
diff --git a/src/modules/message/message-type-backfill.service.spec.ts b/src/modules/message/message-type-backfill.service.spec.tsindex 629d4f41a..f94a97de1 100644--- a/src/modules/message/message-type-backfill.service.spec.ts+++ b/src/modules/message/message-type-backfill.service.spec.ts@@ -12,8 +12,13 @@ describe('MessageTypeBackfillService', () => {const update = jest.fn().mockResolvedValue({ affected: 1 });await makeService(update).onApplicationBootstrap();- expect(update).toHaveBeenCalledTimes(3);+ expect(update).toHaveBeenCalledTimes(4);expect(update).toHaveBeenCalledWith({ type: 'chat' }, { type: 'text' });+ // A tapped button, list row or template button: text, as mapWwebjsMessageType now reports them.+ expect(update).toHaveBeenCalledWith(+ { type: In(['buttons_response', 'list_response', 'template_button_reply']) },+ { type: 'text' },+ );expect(update).toHaveBeenCalledWith({ type: 'ptt' }, { type: 'voice' });// vcard + multi_vcard collapse to contact via an IN clauseexpect(update).toHaveBeenCalledWith({ type: In(['vcard', 'multi_vcard']) }, { type: 'contact' });@@ -22,7 +27,7 @@ describe('MessageTypeBackfillService', () => {it('is a no-op-safe write (idempotent): affected:0 on already-neutral rows does not throw', async () => {const update = jest.fn().mockResolvedValue({ affected: 0 });await expect(makeService(update).onApplicationBootstrap()).resolves.toBeUndefined();- expect(update).toHaveBeenCalledTimes(3);+ expect(update).toHaveBeenCalledTimes(4);});it('does not crash boot if the backfill query fails', async () => {diff --git a/src/modules/message/message-type-backfill.service.ts b/src/modules/message/message-type-backfill.service.tsindex 034396b12..63ceaf87e 100644--- a/src/modules/message/message-type-backfill.service.ts+++ b/src/modules/message/message-type-backfill.service.ts@@ -32,6 +32,7 @@ export class MessageTypeBackfillService implements OnApplicationBootstrap {// [legacy wwebjs token(s)] -> neutral MessageType. Kept in sync with mapWwebjsMessageType.const conversions: Array<{ from: string[]; to: string }> = [{ from: ['chat'], to: 'text' },+ { from: ['buttons_response', 'list_response', 'template_button_reply'], to: 'text' },{ from: ['ptt'], to: 'voice' },{ from: ['vcard', 'multi_vcard'], to: 'contact' },];