diff --git a/utils/contacts.go b/utils/contacts.go index 1fbb554..cd9e7e4 100644 --- a/utils/contacts.go +++ b/utils/contacts.go @@ -4,6 +4,7 @@ import "cwtch.im/cwtch/model" type Contact struct { Name string `json:"name"` + LocalName string `json:"localname"` Onion string `json:"onion"` Status string `json:"status"` Picture string `json:"picture"` diff --git a/utils/eventHandler.go b/utils/eventHandler.go index 1945b7c..ecb12e7 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -217,12 +217,14 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { } // Prefer local override to public name... - name, exists := conversationInfo.GetAttribute(attr.LocalScope, attr.ProfileZone, constants.Name) + localname, exists := conversationInfo.GetAttribute(attr.LocalScope, attr.ProfileZone, constants.Name) if !exists { - name, exists = conversationInfo.GetAttribute(attr.PublicScope, attr.ProfileZone, constants.Name) - if !exists { - name = conversationInfo.Handle - } + localname = "" + } + + name, exists := conversationInfo.GetAttribute(attr.PublicScope, attr.ProfileZone, constants.Name) + if !exists { + name = conversationInfo.Handle } // Resolve the profile image of the contact @@ -303,6 +305,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { contacts = append(contacts, Contact{ Name: name, + LocalName: localname, Identifier: conversationInfo.ID, Onion: conversationInfo.Handle, Status: connections.ConnectionStateName[state],