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.
main
borja 1 month ago
parent 5c1d2f2251
commit fcaafc4600

@ -372,7 +372,8 @@ async function handleTaskCommand(
/** True when the message should be forwarded to the command service. */ /** True when the message should be forwarded to the command service. */
function isTaskCommand(text: string): boolean { function isTaskCommand(text: string): boolean {
return text.startsWith('tarea ') || text.startsWith('t '); const lower = text.toLowerCase();
return lower.startsWith('tarea ') || lower.startsWith('t ');
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

@ -148,6 +148,42 @@ describe('WebhookServer — Basic validation', () => {
expect(SimulatedResponseQueue.get().length).toBe(0); 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 () => { test('should ignore message with mentions but no command', async () => {
const payload = { const payload = {
event: 'messages.upsert', event: 'messages.upsert',

Loading…
Cancel
Save