commit 6571a68e64d099c76bb43c6a5af78b23a31466b9
Author: Nathanaƫl <contact@nathanaelhoun.fr>
Date: Thu Jun 25 00:35:49 2020 +0000
diff --git a/bridge/whatsapp/helpers.go b/bridge/whatsapp/helpers.go
index f45d624..aa5f318 100644
--- a/bridge/whatsapp/helpers.go
+++ b/bridge/whatsapp/helpers.go
@@ -808 +8033 @@ func (b *Bwhatsapp) getSenderName(senderJid string) string {
// if user is not in phone contacts
// it is the most obvious scenario unless you sync your phone contacts with some remote updated source
// users can change it in their WhatsApp settings -> profile -> click on Avatar
- return sender.Notify
+ if sender.Notify != "" {
+ return sender.Notify
+ }
+
+ if sender.Short != "" {
+ return sender.Short
+ }
+ }
+
+ // try to reload this contact
+ _, err := b.conn.Contacts()
+ if err != nil {
+ b.Log.Errorf("error on update of contacts: %v", err)
}
+
+ if contact, exists := b.conn.Store.Contacts[senderJid]; exists {
+ // Add it to the user map
+ b.users[senderJid] = contact
+
+ if contact.Name != "" {
+ return contact.Name
+ }
+ // if user is not in phone contacts
+ // same as above
+ return contact.Notify
+ }
+
return ""
}