Skip to content

The agent that grows with you

fix(whatsapp): strip :<device> suffix in normalizeWhatsAppId

ebs6bf10326098b
diff --git a/scripts/whatsapp-bridge/bridge.js b/scripts/whatsapp-bridge/bridge.js
index 408203b500f..2101017c42c 100644
--- a/scripts/whatsapp-bridge/bridge.js
+++ b/scripts/whatsapp-bridge/bridge.js
@@ -207,7 +207,11 @@ function trackSentMessageId(sent) {
function normalizeWhatsAppId(value) {
if (!value) return '';
- return String(value).replace(':', '@');
+ // Strip the :<device> suffix (e.g. 447999674698:[email protected] -> [email protected])
+ // so bot/mention/quoted ids compare consistently. The old .replace(':','@') produced a
+ // malformed '...@14@lid', which never matched the bot's own id (breaking @mention and
+ // reply-to-bot detection in groups).
+ return String(value).replace(/:\d+@/, '@').replace(/:\d+$/, '');
}
function redactWhatsAppId(value) {