From fcaafc46006859660bb763100936958b8020347f Mon Sep 17 00:00:00 2001 From: borja Date: Sat, 2 May 2026 00:26:54 +0200 Subject: [PATCH] fix: accept uppercase T/Tarea command prefixes from mobile keyboards Make isTaskCommand in webhook-handler case-insensitive so that 'T ' and 'Tarea ' are recognized as task commands (mobile keyboards auto-capitalize the first character). Add tests for both variants. --- src/http/webhook-handler.ts | 3 ++- tests/unit/server.basic.test.ts | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/http/webhook-handler.ts b/src/http/webhook-handler.ts index 885f773..0b380b4 100644 --- a/src/http/webhook-handler.ts +++ b/src/http/webhook-handler.ts @@ -372,7 +372,8 @@ async function handleTaskCommand( /** True when the message should be forwarded to the command service. */ function isTaskCommand(text: string): boolean { - return text.startsWith('tarea ') || text.startsWith('t '); + const lower = text.toLowerCase(); + return lower.startsWith('tarea ') || lower.startsWith('t '); } // --------------------------------------------------------------------------- diff --git a/tests/unit/server.basic.test.ts b/tests/unit/server.basic.test.ts index 1f626c0..3937248 100644 --- a/tests/unit/server.basic.test.ts +++ b/tests/unit/server.basic.test.ts @@ -148,6 +148,42 @@ describe('WebhookServer — Basic validation', () => { expect(SimulatedResponseQueue.get().length).toBe(0); }); + test('should process command with uppercase T prefix (T area)', async () => { + const payload = { + event: 'messages.upsert', + instance: 'test-instance', + data: { + key: { + remoteJid: 'group-id@g.us', + participant: 'sender-id@s.whatsapp.net', + }, + message: { conversation: 'T n Test uppercase T' }, + }, + }; + const request = createTestRequest(payload); + const response = await WebhookServer.handleRequest(request); + expect(response.status).toBe(200); + expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0); + }); + + test('should process command with uppercase Tarea prefix', async () => { + const payload = { + event: 'messages.upsert', + instance: 'test-instance', + data: { + key: { + remoteJid: 'group-id@g.us', + participant: 'sender-id@s.whatsapp.net', + }, + message: { conversation: 'Tarea nueva Test uppercase Tarea' }, + }, + }; + const request = createTestRequest(payload); + const response = await WebhookServer.handleRequest(request); + expect(response.status).toBe(200); + expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0); + }); + test('should ignore message with mentions but no command', async () => { const payload = { event: 'messages.upsert',