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{}
for memberID, member := range community.Members() {
for _, revealedAddress := range member.RevealedAccounts {
if slices.Contains(revealedAddress.ChainIds, chainID) {
contact, ok := m.allContacts.Load(memberID)
if ok {
membersForAddresses[revealedAddress.Address] = contact
} else {
m.logger.Error("community member is not a contact", zap.String("contact ID", memberID))
}
for _, memberPubKey := range community.GetMemberPubkeys() {
memberPubKeyStr := common.PubkeyToHex(memberPubKey)
revealedAccounts, err := m.communitiesManager.GetRevealedAddresses(communityID, memberPubKeyStr)
if err != nil {
return nil, err
}
for _, revealedAccount := range revealedAccounts {
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))
}
}
}