2022-12-02 11:34:02 +00:00
|
|
|
package requests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ErrAddRoleToMemberInvalidCommunityID = errors.New("add-role-to-member: invalid community id")
|
|
|
|
var ErrAddRoleToMemberInvalidUser = errors.New("add-role-to-member: invalid user id")
|
|
|
|
var ErrAddRoleToMemberInvalidRole = errors.New("add-role-to-member: invalid role")
|
|
|
|
|
|
|
|
type AddRoleToMember struct {
|
|
|
|
CommunityID types.HexBytes `json:"communityId"`
|
|
|
|
User types.HexBytes `json:"user"`
|
|
|
|
Role protobuf.CommunityMember_Roles `json:"role"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *AddRoleToMember) Validate() error {
|
|
|
|
if len(a.CommunityID) == 0 {
|
|
|
|
return ErrAddRoleToMemberInvalidCommunityID
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(a.User) == 0 {
|
|
|
|
return ErrAddRoleToMemberInvalidUser
|
|
|
|
}
|
|
|
|
|
2023-06-14 14:15:46 +00:00
|
|
|
if a.Role == protobuf.CommunityMember_ROLE_NONE {
|
2022-12-02 11:34:02 +00:00
|
|
|
return ErrAddRoleToMemberInvalidRole
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|