Browse Source

fix: normalize lid addresses

pull/291/head
almogbaku 9 months ago
parent
commit
86143f9622
No known key found for this signature in database GPG Key ID: 66C92B1C5B475512
  1. 11
      src/pkg/whatsapp/webhook.go

11
src/pkg/whatsapp/webhook.go

@ -2,9 +2,12 @@ package whatsapp
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"go.mau.fi/whatsmeow/types"
"net/http" "net/http"
"strings"
"time" "time"
"github.com/aldinokemal/go-whatsapp-web-multidevice/config" "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 != "" { if from := evt.Info.SourceString(); from != "" {
body["from"] = 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 != "" { if message.ID != "" {
body["message"] = message body["message"] = message

Loading…
Cancel
Save