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