Avoid concurrent access to contacts
We were not locking before accessing the contacts map and it would panic in some cases. I have changed the code to pull contacts from db so we move away from having locks.
This commit is contained in:
parent
e5115d60f1
commit
ee8f333dbf
|
@ -3292,7 +3292,11 @@ func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*common
|
|||
|
||||
if chat.Timeline() {
|
||||
var chatIDs = []string{"@" + contactIDFromPublicKey(&m.identity.PublicKey)}
|
||||
for _, contact := range m.allContacts {
|
||||
contacts, err := m.persistence.Contacts()
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
for _, contact := range contacts {
|
||||
if contact.IsAdded() {
|
||||
chatIDs = append(chatIDs, "@"+contact.ID)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue