GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
fix: user check always returning true for invalid numbers (issue #496)
Aldino Kemal346fb32ecad7
diff --git a/src/pkg/utils/whatsapp.go b/src/pkg/utils/whatsapp.goindex 24d40562..ac875207 100644--- a/src/pkg/utils/whatsapp.go+++ b/src/pkg/utils/whatsapp.go@@ -609,21 +609,41 @@ func SanitizePhone(phone *string) {// IsOnWhatsapp checks if a number is registered on WhatsAppfunc IsOnWhatsapp(client *whatsmeow.Client, jid string) bool {- // only check if the jid a user with @s.whatsapp.net+ // only check if the jid is a user with @s.whatsapp.netif strings.Contains(jid, "@s.whatsapp.net") {- data, err := client.IsOnWhatsApp(context.Background(), []string{jid})+ // Extract phone number from JID and add + prefix for international format+ phone := strings.TrimSuffix(jid, "@s.whatsapp.net")+ if phone == "" {+ return false+ }++ // whatsmeow expects international format with + prefix+ if !strings.HasPrefix(phone, "+") {+ phone = "+" + phone+ }++ data, err := client.IsOnWhatsApp(context.Background(), []string{phone})if err != nil {logrus.Error("Failed to check if user is on whatsapp: ", err)return false}+ // Empty response means number not found/invalid+ if len(data) == 0 {+ return false+ }++ // Check if any result indicates the number is NOT on WhatsAppfor _, v := range data {if !v.IsIn {return false}}++ return true}+ // For non-user JIDs (groups, newsletters), skip validationreturn true}