status-go/protocol/requests/reorder_community_chat.go
RichΛrd fe086b2fdd
fix: allow empty category id when sorting chats and fix error messages (#2301)
* fix: allow empty category id when sorting chats and fix error messages
* fix: unordered maps
2021-08-25 12:52:28 -04:00

35 lines
921 B
Go

package requests
import (
"errors"
"github.com/status-im/status-go/eth-node/types"
)
var ErrReorderCommunityChatInvalidCommunityID = errors.New("reorder-community-chat: invalid community id")
var ErrReorderCommunityChatInvalidChatID = errors.New("reorder-community-chat: invalid chat id")
var ErrReorderCommunityChatInvalidPosition = errors.New("reorder-community-chat: invalid position")
type ReorderCommunityChat struct {
CommunityID types.HexBytes `json:"communityId"`
CategoryID string `json:"categoryId"`
ChatID string `json:"chatId"`
Position int `json:"position"`
}
func (j *ReorderCommunityChat) Validate() error {
if len(j.CommunityID) == 0 {
return ErrReorderCommunityChatInvalidCommunityID
}
if len(j.ChatID) == 0 {
return ErrReorderCommunityChatInvalidChatID
}
if j.Position < 0 {
return ErrReorderCommunityCategoryInvalidPosition
}
return nil
}