Fix fetching revealed accounts in `GetCommunityMembersForWalletAddresses` (#3891)

https://github.com/status-im/status-desktop/issues/11143
This commit is contained in:
Mikhail Rogachev 2023-08-17 02:05:32 +04:00 committed by GitHub
parent 1a05c84585
commit 6d3e6d1b5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 9 deletions

View File

@ -4506,15 +4506,22 @@ func (m *Messenger) GetCommunityMembersForWalletAddresses(communityID types.HexB
membersForAddresses := map[string]*Contact{} membersForAddresses := map[string]*Contact{}
for memberID, member := range community.Members() { for _, memberPubKey := range community.GetMemberPubkeys() {
for _, revealedAddress := range member.RevealedAccounts { memberPubKeyStr := common.PubkeyToHex(memberPubKey)
if slices.Contains(revealedAddress.ChainIds, chainID) { revealedAccounts, err := m.communitiesManager.GetRevealedAddresses(communityID, memberPubKeyStr)
contact, ok := m.allContacts.Load(memberID) if err != nil {
if ok { return nil, err
membersForAddresses[revealedAddress.Address] = contact }
} else { for _, revealedAccount := range revealedAccounts {
m.logger.Error("community member is not a contact", zap.String("contact ID", memberID)) if !slices.Contains(revealedAccount.ChainIds, chainID) {
} continue
}
contact, ok := m.allContacts.Load(memberPubKeyStr)
if ok {
membersForAddresses[revealedAccount.Address] = contact
} else {
m.logger.Error("community member is not a contact", zap.String("contact ID", memberPubKeyStr))
} }
} }
} }