mirror of
https://github.com/status-im/status-go.git
synced 2025-02-13 07:17:04 +00:00
Improve `RequestToJoinCommunity` to accept `Addresses` in the request. If `Addresses` is not empty, we then only pass to the owner the selected addresses. The others are ignored. Does not validate that the addresses in the slice are part of the user's wallet. Those not part of the wallet are just ignored.
29 lines
866 B
Go
29 lines
866 B
Go
package requests
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
)
|
|
|
|
var ErrRequestToJoinCommunityInvalidCommunityID = errors.New("request-to-join-community: invalid community id")
|
|
var ErrRequestToJoinCommunityMissingPassword = errors.New("request-to-join-community: password is necessary when sending a list of addresses")
|
|
|
|
type RequestToJoinCommunity struct {
|
|
CommunityID types.HexBytes `json:"communityId"`
|
|
ENSName string `json:"ensName"`
|
|
Password string `json:"password"`
|
|
AddressesToReveal []string `json:"addressesToReveal"`
|
|
}
|
|
|
|
func (j *RequestToJoinCommunity) Validate() error {
|
|
if len(j.CommunityID) == 0 {
|
|
return ErrRequestToJoinCommunityInvalidCommunityID
|
|
}
|
|
if len(j.AddressesToReveal) > 0 && j.Password == "" {
|
|
return ErrRequestToJoinCommunityMissingPassword
|
|
}
|
|
|
|
return nil
|
|
}
|