diff options
author | Joseph Mansy <36427684+yousefmansy1@users.noreply.github.com> | 2023-03-14 15:12:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 23:12:45 +0100 |
commit | d42277979abcefe885bb068cad989eaf71460872 (patch) | |
tree | 28627bc93cd50851af1c791d496394e379fc4ae9 /bridge/whatsappmulti/helpers.go | |
parent | 24cf007a74bf1e04456ae05c9ccc73b1fb823b88 (diff) | |
download | matterbridge-msglm-d42277979abcefe885bb068cad989eaf71460872.tar.gz matterbridge-msglm-d42277979abcefe885bb068cad989eaf71460872.tar.bz2 matterbridge-msglm-d42277979abcefe885bb068cad989eaf71460872.zip |
Support topic changes and Join/Leave messages (whatsapp) (#2017)
Diffstat (limited to 'bridge/whatsappmulti/helpers.go')
-rw-r--r-- | bridge/whatsappmulti/helpers.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bridge/whatsappmulti/helpers.go b/bridge/whatsappmulti/helpers.go index 963eafa1..b0686190 100644 --- a/bridge/whatsappmulti/helpers.go +++ b/bridge/whatsappmulti/helpers.go @@ -64,6 +64,29 @@ func (b *Bwhatsapp) getSenderName(info types.MessageInfo) string { return "Someone" } +func (b *Bwhatsapp) getSenderNameFromJID(senderJid types.JID) string { + sender, exists := b.contacts[senderJid] + + if !exists || (sender.FullName == "" && sender.FirstName == "") { + b.reloadContacts() // Contacts may need to be reloaded + sender, exists = b.contacts[senderJid] + } + + if exists && sender.FullName != "" { + return sender.FullName + } + + if exists && sender.FirstName != "" { + return sender.FirstName + } + + if sender.PushName != "" { + return sender.PushName + } + + return "Someone" +} + func (b *Bwhatsapp) getSenderNotify(senderJid types.JID) string { sender, exists := b.contacts[senderJid] |