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

     1  package requests
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/status-im/status-go/eth-node/types"
     7  )
     8  
     9  // errrors
    10  var (
    11  	ErrImportDiscordChannelMissingFilesToImport = errors.New("import-discord-channel: missing files to import")
    12  	ErrImportDiscordChannelChannelIDIsEmpty     = errors.New("import-discord-channel: discord channel id is empty")
    13  	ErrImportDiscordChannelCommunityIDIsEmpty   = errors.New("import-discord-channel: community id is empty")
    14  )
    15  
    16  type ImportDiscordChannel struct {
    17  	Name             string         `json:"name"`
    18  	DiscordChannelID string         `json:"discordChannelID"`
    19  	CommunityID      types.HexBytes `json:"communityId"`
    20  	Description      string         `json:"description"`
    21  	Color            string         `json:"color"`
    22  	Emoji            string         `json:"emoji"`
    23  	FilesToImport    []string       `json:"filesToImport"`
    24  	From             int64          `json:"from"`
    25  }
    26  
    27  func (r *ImportDiscordChannel) Validate() error {
    28  	if len(r.FilesToImport) == 0 {
    29  		return ErrImportDiscordChannelMissingFilesToImport
    30  	}
    31  
    32  	if len(r.DiscordChannelID) == 0 {
    33  		return ErrImportDiscordChannelChannelIDIsEmpty
    34  	}
    35  
    36  	if len(r.CommunityID) == 0 {
    37  		return ErrImportDiscordChannelCommunityIDIsEmpty
    38  	}
    39  
    40  	return nil
    41  }