diff --git a/protocol/messenger.go b/protocol/messenger.go index fca58caf7..092d18013 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -1234,14 +1234,11 @@ func (m *Messenger) Contacts() []*Contact { } // GetContactByID assumes pubKey includes 0x prefix -func (m *Messenger) GetContactByID(pubKey string) (*Contact, error) { +func (m *Messenger) GetContactByID(pubKey string) *Contact { m.mutex.Lock() defer m.mutex.Unlock() - contact, ok := m.allContacts[pubKey] - if !ok { - return nil, errors.New("no contact found") - } - return contact, nil + + return m.allContacts[pubKey] } // ReSendChatMessage pulls a message from the database and sends it again diff --git a/services/ext/api.go b/services/ext/api.go index fe9356c48..7da2a6537 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -260,6 +260,10 @@ func (api *PublicAPI) Contacts(parent context.Context) []*protocol.Contact { return api.service.messenger.Contacts() } +func (api *PublicAPI) GetContactByID(parent context.Context, id string) *protocol.Contact { + return api.service.messenger.GetContactByID(id) +} + func (api *PublicAPI) RemoveFilters(parent context.Context, chats []*transport.Filter) error { return api.service.messenger.RemoveFilters(chats) }