feat(communities): add addresses to check channel permissions functions (#3910)

This commit is contained in:
Jonathan Rainville 2023-08-18 15:50:23 -04:00 committed by GitHub
parent c0c74010e7
commit 5272f99b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 14 deletions

View File

@ -4370,15 +4370,21 @@ func (m *Messenger) CheckCommunityChannelPermissions(request *requests.CheckComm
return nil, err
}
accounts, err := m.settings.GetActiveAccounts()
if err != nil {
return nil, err
}
var addresses []gethcommon.Address
for _, a := range accounts {
addresses = append(addresses, gethcommon.HexToAddress(a.Address.Hex()))
if len(request.Addresses) == 0 {
accounts, err := m.settings.GetActiveAccounts()
if err != nil {
return nil, err
}
for _, a := range accounts {
addresses = append(addresses, gethcommon.HexToAddress(a.Address.Hex()))
}
} else {
for _, v := range request.Addresses {
addresses = append(addresses, gethcommon.HexToAddress(v))
}
}
return m.communitiesManager.CheckChannelPermissions(request.CommunityID, request.ChatID, addresses)
@ -4389,15 +4395,21 @@ func (m *Messenger) CheckAllCommunityChannelsPermissions(request *requests.Check
return nil, err
}
accounts, err := m.settings.GetActiveAccounts()
if err != nil {
return nil, err
}
var addresses []gethcommon.Address
for _, a := range accounts {
addresses = append(addresses, gethcommon.HexToAddress(a.Address.Hex()))
if len(request.Addresses) == 0 {
accounts, err := m.settings.GetActiveAccounts()
if err != nil {
return nil, err
}
for _, a := range accounts {
addresses = append(addresses, gethcommon.HexToAddress(a.Address.Hex()))
}
} else {
for _, v := range request.Addresses {
addresses = append(addresses, gethcommon.HexToAddress(v))
}
}
return m.communitiesManager.CheckAllChannelsPermissions(request.CommunityID, addresses)

View File

@ -12,6 +12,7 @@ var (
type CheckAllCommunityChannelsPermissions struct {
CommunityID types.HexBytes
Addresses []string `json:"addresses"`
}
func (u *CheckAllCommunityChannelsPermissions) Validate() error {

View File

@ -14,6 +14,7 @@ var (
type CheckCommunityChannelPermissions struct {
CommunityID types.HexBytes
ChatID string
Addresses []string `json:"addresses"`
}
func (u *CheckCommunityChannelPermissions) Validate() error {