From 52412fb4ccf3070166f9a07246dbe2ae4dea1753 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Tue, 13 Jan 2026 16:40:12 +0700 Subject: [PATCH] [core] ChatWoot - remove @lid when mention it fix #1803 --- .../chatwoot/messages/to/whatsapp/mentions.test.ts | 10 +++++++++- src/apps/chatwoot/messages/to/whatsapp/mentions.ts | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts b/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts index 1cd27cf1..eab00220 100644 --- a/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts +++ b/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts @@ -108,8 +108,16 @@ describe('parseMentionsFromText', () => { it('parses @lid mentions without c.us suffix', () => { const input = 'Notify @123123@lid now'; expect(parseMentionsFromText(input)).toEqual({ - text: 'Notify @123123@lid now', + text: 'Notify @123123 now', mentions: ['123123@lid'], }); }); + + it('replaces @lid suffix with plain ids', () => { + const input = '@123456@lid please ping @654321@lid.'; + expect(parseMentionsFromText(input)).toEqual({ + text: '@123456 please ping @654321.', + mentions: ['123456@lid', '654321@lid'], + }); + }); }); diff --git a/src/apps/chatwoot/messages/to/whatsapp/mentions.ts b/src/apps/chatwoot/messages/to/whatsapp/mentions.ts index 5090565a..2c3cd6cd 100644 --- a/src/apps/chatwoot/messages/to/whatsapp/mentions.ts +++ b/src/apps/chatwoot/messages/to/whatsapp/mentions.ts @@ -40,6 +40,10 @@ export function parseMentionsFromText(text: string): ParsedMentions { mentions.push(formattedLid); } } + if (mentions.length > 0) { + const lidRegexReplace = /(^|\s)@(\d{6,15})@lid\b/g; + content = content.replace(lidRegexReplace, '$1@$2').trim(); + } // Regex to match @ followed by phone number // Matches: @558591203123, @5585991203123, etc.