This commit is contained in:
Iiro Laiho
2022-12-02 22:43:37 +02:00
parent a975b145da
commit fe39c5a9d5
2 changed files with 9 additions and 17 deletions

View File

@@ -52,9 +52,6 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
channel := messageInfo.Chat
senderName := b.getSenderName(messageInfo)
if senderName == "" {
senderName = "Someone" // don't expose telephone number
}
if msg.GetExtendedTextMessage() == nil && msg.GetConversation() == "" {
b.Log.Debugf("message without text content? %#v", msg)
@@ -82,9 +79,6 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
// mentions comes as telephone numbers and we don't want to expose it to other bridges
// replace it with something more meaninful to others
mention := b.getSenderNotify(types.NewJID(numberAndSuffix[0], types.DefaultUserServer))
if mention == "" {
mention = "someone"
}
text = strings.Replace(text, "@"+numberAndSuffix[0], "@"+mention, 1)
}

View File

@@ -18,17 +18,19 @@ type ProfilePicInfo struct {
Status int16 `json:"status"`
}
func (b *Bwhatsapp) getSenderName(info types.MessageInfo) string {
// Parse AD JID
var senderJid types.JID
senderJid.User, senderJid.Server = info.Sender.User, info.Sender.Server
sender, exists := b.contacts[senderJid]
for i := 0; i < 2; i++ {
if sender, exists := b.contacts[senderJid]; exists {
if sender.FullName != "" {
return sender.FullName
}
if exists && ( sender.FullName != "" ) {
return sender.FullName
}
// 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
@@ -36,10 +38,8 @@ func (b *Bwhatsapp) getSenderName(info types.MessageInfo) string {
return info.PushName
}
if sender, exists := b.contacts[senderJid]; exists {
if sender.FirstName != "" {
return sender.FirstName
}
if exists && ( sender.FirstName != "" ) {
return sender.FirstName
}
if i > 0 {
@@ -60,7 +60,6 @@ func (b *Bwhatsapp) getSenderName(info types.MessageInfo) string {
b.contacts = allcontacts
}
}
return "Someone"
}
@@ -68,8 +67,7 @@ func (b *Bwhatsapp) getSenderNotify(senderJid types.JID) string {
if sender, exists := b.contacts[senderJid]; exists {
return sender.PushName
}
return ""
return "someone"
}
func (b *Bwhatsapp) GetProfilePicThumb(jid string) (*types.ProfilePictureInfo, error) {