expose getContactByID method

This commit is contained in:
Andrea Maria Piana 2020-06-04 15:32:47 +02:00
parent 82deccef60
commit 4720224ba2
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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)
}