diff --git a/go/characters/cwtchlistener.go b/go/characters/cwtchlistener.go index 1bb21fe..4320f41 100644 --- a/go/characters/cwtchlistener.go +++ b/go/characters/cwtchlistener.go @@ -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, }) } -} \ No newline at end of file +}