add GetContactByID to Messenger

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-02-13 12:20:45 +01:00 committed by Jakub
parent 19fc448c85
commit 7a97325850
1 changed files with 11 additions and 1 deletions

View File

@ -1147,10 +1147,20 @@ func (m *Messenger) Contacts() []*Contact {
for _, contact := range m.allContacts {
contacts = append(contacts, contact)
}
return contacts
}
// GetContactByID assumes pubKey includes 0x prefix
func (m *Messenger) GetContactByID(pubKey string) (*Contact, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
contact, ok := m.allContacts[pubKey]
if !ok {
return nil, errors.New("no contact found")
}
return contact, nil
}
// ReSendChatMessage pulls a message from the database and sends it again
func (m *Messenger) ReSendChatMessage(ctx context.Context, messageID string) error {
m.mutex.Lock()