Merge branch 'bugfix' of erinn/bounce into master

This commit is contained in:
erinn 2018-11-28 19:36:22 +00:00 committed by Gogs
commit 45da4d33cb
1 changed files with 8 additions and 11 deletions

View File

@ -1,9 +1,9 @@
package characters
import (
"cwtch.im/cwtch/model"
"bounce/go/the"
"bounce/go/gobjects"
"bounce/go/the"
"cwtch.im/cwtch/model"
)
func CwtchListener(callback func(message *gobjects.Message), groupID string, channel chan model.Message) {
@ -14,17 +14,14 @@ func CwtchListener(callback func(message *gobjects.Message), groupID string, cha
if name == the.Peer.GetProfile().Onion {
name = "me"
} else {
var exists bool // lol this is a golang antifeature
name, exists = the.Peer.GetContact(m.PeerID).GetAttribute("name")
if !exists {
name = ""
contact := the.Peer.GetContact(m.PeerID)
if contact != nil {
name, _ = contact.GetAttribute("name")
} else {
name = m.PeerID[:16] + "..."
}
}
if name == "" {
name = m.PeerID[:16] + "..."
}
callback(&gobjects.Message{
groupID,
m.PeerID,
@ -36,4 +33,4 @@ func CwtchListener(callback func(message *gobjects.Message), groupID string, cha
m.Timestamp,
})
}
}
}