feat(api): add api to get members revealed accounts (#3864)

This commit is contained in:
Jonathan Rainville 2023-08-09 11:08:20 -04:00 committed by GitHub
parent 4b394e088e
commit b4b0d26aa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -1136,6 +1136,27 @@ func (m *Messenger) EditSharedAddressesForCommunity(request *requests.EditShared
return response, nil
}
func (m *Messenger) GetRevealedAccounts(communityID types.HexBytes, memberPk string) ([]*protobuf.RevealedAccount, error) {
return m.communitiesManager.GetRevealedAddresses(communityID, memberPk)
}
func (m *Messenger) GetRevealedAccountsForAllMembers(communityID types.HexBytes) (map[string][]*protobuf.RevealedAccount, error) {
community, err := m.communitiesManager.GetByID(communityID)
if err != nil {
return nil, err
}
membersRevealedAccounts := map[string][]*protobuf.RevealedAccount{}
for _, memberPubKey := range community.GetMemberPubkeys() {
memberPubKeyStr := common.PubkeyToHex(memberPubKey)
accounts, err := m.communitiesManager.GetRevealedAddresses(communityID, memberPubKeyStr)
if err != nil {
return nil, err
}
membersRevealedAccounts[memberPubKeyStr] = accounts
}
return membersRevealedAccounts, nil
}
func (m *Messenger) CreateCommunityCategory(request *requests.CreateCommunityCategory) (*MessengerResponse, error) {
if err := request.Validate(); err != nil {
return nil, err

View File

@ -587,6 +587,16 @@ func (api *PublicAPI) EditSharedAddressesForCommunity(request *requests.EditShar
return api.service.messenger.EditSharedAddressesForCommunity(request)
}
// GetRevealedAccounts gets the revealed addresses for a member in a community
func (api *PublicAPI) GetRevealedAccounts(communityID types.HexBytes, memberPk string) ([]*protobuf.RevealedAccount, error) {
return api.service.messenger.GetRevealedAccounts(communityID, memberPk)
}
// GetRevealedAccountsForAllMembers gets the revealed addresses for all the members of a community
func (api *PublicAPI) GetRevealedAccountsForAllMembers(communityID types.HexBytes) (map[string][]*protobuf.RevealedAccount, error) {
return api.service.messenger.GetRevealedAccountsForAllMembers(communityID)
}
// CheckAndClearPendingRequestToJoinCommunity to delete pending request to join a community which are older than 7 days
func (api *PublicAPI) CheckAndDeletePendingRequestToJoinCommunity() (*protocol.MessengerResponse, error) {
return api.service.messenger.CheckAndDeletePendingRequestToJoinCommunity(true)