From 86143f962276b0ff58f9c6b574c274f4564a90a2 Mon Sep 17 00:00:00 2001 From: almogbaku Date: Tue, 3 Jun 2025 12:32:59 -0700 Subject: [PATCH] fix: normalize lid addresses --- src/pkg/whatsapp/webhook.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pkg/whatsapp/webhook.go b/src/pkg/whatsapp/webhook.go index 5a1dc24..4529a34 100644 --- a/src/pkg/whatsapp/webhook.go +++ b/src/pkg/whatsapp/webhook.go @@ -2,9 +2,12 @@ package whatsapp import ( "bytes" + "context" "encoding/json" "fmt" + "go.mau.fi/whatsmeow/types" "net/http" + "strings" "time" "github.com/aldinokemal/go-whatsapp-web-multidevice/config" @@ -40,6 +43,14 @@ func createPayload(evt *events.Message) (map[string]interface{}, error) { if from := evt.Info.SourceString(); from != "" { body["from"] = from + if strings.HasSuffix(body["from"].(string), "@lid") { + body["from_lid"] = body["from"] + jid, _ := types.ParseJID(body["from"].(string)) + pn, _ := cli.Store.LIDs.GetPNForLID(context.Background(), jid) + if !pn.IsEmpty() { + body["from"] = pn.String() + } + } } if message.ID != "" { body["message"] = message