github.com/status-im/status-go@v1.1.0/protocol/requests/reorder_community_chat.go (about)

     1  package requests
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/status-im/status-go/eth-node/types"
     7  )
     8  
     9  var ErrReorderCommunityChatInvalidCommunityID = errors.New("reorder-community-chat: invalid community id")
    10  var ErrReorderCommunityChatInvalidChatID = errors.New("reorder-community-chat: invalid chat id")
    11  var ErrReorderCommunityChatInvalidPosition = errors.New("reorder-community-chat: invalid position")
    12  
    13  type ReorderCommunityChat struct {
    14  	CommunityID types.HexBytes `json:"communityId"`
    15  	CategoryID  string         `json:"categoryId"`
    16  	ChatID      string         `json:"chatId"`
    17  	Position    int            `json:"position"`
    18  }
    19  
    20  func (j *ReorderCommunityChat) Validate() error {
    21  	if len(j.CommunityID) == 0 {
    22  		return ErrReorderCommunityChatInvalidCommunityID
    23  	}
    24  
    25  	if len(j.ChatID) == 0 {
    26  		return ErrReorderCommunityChatInvalidChatID
    27  	}
    28  
    29  	if j.Position < 0 {
    30  		return ErrReorderCommunityCategoryInvalidPosition
    31  	}
    32  
    33  	return nil
    34  }