[core] ChatWoot - support @lid mention directly

fix #1767
closes devlikeapro/waha-plus#36
This commit is contained in:
devlikepro committed 2026-01-12 16:50:32 +07:00
1 parent cb1faff88c
commit f02d95331a
2 files changed
+20 -1

No files matched your search

@@ -104,4 +104,12 @@ describe('parseMentionsFromText', () => {
mentions: ['1231234@c.us', '5555555@c.us'],
});
});
it('parses @lid mentions without c.us suffix', () => {
const input = 'Notify @123123@lid now';
expect(parseMentionsFromText(input)).toEqual({
text: 'Notify @123123@lid now',
mentions: ['123123@lid'],
});
});
});
@@ -30,10 +30,21 @@ export function parseMentionsFromText(text: string): ParsedMentions {
content = content.replace(allRegexReplace, '$1').trim();
}
const lidRegex = /(^|\s)@(\d{6,15})@lid\b/g;
const lidMatches = text.matchAll(lidRegex);
for (const match of lidMatches) {
const lidNumber = match[2];
const formattedLid = `${lidNumber}@lid`;
if (!mentions.includes(formattedLid)) {
mentions.push(formattedLid);
}
}
// Regex to match @ followed by phone number
// Matches: @558591203123, @5585991203123, etc.
// Phone numbers: 7-15 digits (international format)
const phoneRegex = /(^|\s)@(\d{7,15})\b/g;
const phoneRegex = /(^|\s)@(\d{7,15})(?!@lid)\b/g;
const phoneMatches = text.matchAll(phoneRegex);
for (const match of phoneMatches) {