From c33b4d98fd6061c092d2eac1178a989554f3e50f Mon Sep 17 00:00:00 2001 From: Jorge Fernando dos Santos Date: Mon, 9 Nov 2026 12:04:14 -0300 Subject: [PATCH] fix(utils): strip plus prefix from user JIDs in ParseJID Adapted from upstream PR #224 (danie1net0). Queries addressed to "+@s.whatsapp.net" are never answered by WhatsApp and hang until the IQ timeout (upstream issue #223: /user/info and /user/avatar hang 75s). Co-Authored-By: Claude Opus 5.5 --- pkg/utils/utils.go | 9 ++++++++- pkg/utils/utils_test.go | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 0e786c0..b966210 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -207,7 +207,14 @@ func ParseJID(arg string) (whatsmeow_types.JID, bool) { return recipient, false } - if recipient.User == "" && !strings.Contains(jidString, "@broadcast") { + // CreateJID keeps the "+" prefix for IsOnWhatsApp, but it is not part of a + // user JID. WhatsApp does not answer queries addressed to "+", so + // they hang until the IQ timeout (upstream #223 / PR #224). + if recipient.Server == whatsmeow_types.DefaultUserServer { + recipient.User = strings.TrimPrefix(recipient.User, "+") + } + + if recipient.User == "" &&!strings.Contains(jidString, "@broadcast") { logger.LogError("Invalid JID. No user specified: %s", jidString) return recipient, false } diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index 6144514..31cde21 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -284,13 +284,13 @@ func TestParseJID(t *testing.T) { name: "Valid phone number", input: "15551234567", expectOk: true, - expectJID: "+15551234567@s.whatsapp.net", + expectJID: "15551234567@s.whatsapp.net", }, { name: "Valid BR number", input: "5531987654321", expectOk: true, - expectJID: "+553187654321@s.whatsapp.net", + expectJID: "553187654321@s.whatsapp.net", }, { name: "Valid group ID",