Skip to content

Commit b5993ba

Browse files
committed
fix(whatsapp): update phoneJID server validation and clean up struct field formatting
1 parent c97bb25 commit b5993ba

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

internal/messaging/whatsapp_service.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,24 @@ var phoneNumberRegex = regexp.MustCompile(`[^0-9]`)
3535

3636
// WhatsAppService implements Service using the Whatsmeow-based whatsapp client.
3737
type WhatsAppService struct {
38-
client whatsapp.WhatsAppSender
39-
waClient *whatsapp.Client // Access to underlying client for event handling
40-
receipts chan models.Receipt
41-
responses chan models.Response
42-
done chan struct{}
43-
mu sync.RWMutex
44-
stopped bool
45-
lidMu sync.RWMutex
38+
client whatsapp.WhatsAppSender
39+
waClient *whatsapp.Client // Access to underlying client for event handling
40+
receipts chan models.Receipt
41+
responses chan models.Response
42+
done chan struct{}
43+
mu sync.RWMutex
44+
stopped bool
45+
lidMu sync.RWMutex
4646
lidByPhone map[string]string // canonical phone -> JID string for LID addressing
4747
}
4848

4949
// NewWhatsAppService creates a new WhatsAppService wrapping the given WhatsAppSender.
5050
func NewWhatsAppService(client whatsapp.WhatsAppSender) *WhatsAppService {
5151
service := &WhatsAppService{
52-
client: client,
53-
receipts: make(chan models.Receipt, DefaultChannelBufferSize),
54-
responses: make(chan models.Response, DefaultChannelBufferSize),
55-
done: make(chan struct{}),
52+
client: client,
53+
receipts: make(chan models.Receipt, DefaultChannelBufferSize),
54+
responses: make(chan models.Response, DefaultChannelBufferSize),
55+
done: make(chan struct{}),
5656
lidByPhone: make(map[string]string),
5757
}
5858

@@ -423,7 +423,7 @@ func (s *WhatsAppService) handleIncomingMessage(evt *events.Message) {
423423
lidJID = senderAlt
424424
}
425425

426-
if phoneJID.User == "" || phoneJID.Server != types.DefaultUserServer {
426+
if phoneJID.User == "" || (phoneJID.Server != types.DefaultUserServer && phoneJID.Server != types.LegacyUserServer) {
427427
phoneJID = sender
428428
}
429429

0 commit comments

Comments
 (0)