diff --git a/server/model/blocktype.go b/server/model/blocktype.go index 30785655a..41e25ab9d 100644 --- a/server/model/blocktype.go +++ b/server/model/blocktype.go @@ -6,6 +6,8 @@ package model import ( "errors" "strings" + + "github.com/mattermost/focalboard/server/utils" ) // BlockType represents a block type. @@ -24,6 +26,7 @@ func (bt BlockType) String() string { return string(bt) } +// BlockTypeFromString returns an appropriate BlockType for the specified string. func BlockTypeFromString(s string) (BlockType, error) { switch strings.ToLower(s) { case "board": @@ -40,6 +43,21 @@ func BlockTypeFromString(s string) (BlockType, error) { return TypeUnknown, ErrInvalidBlockType{s} } +// BlockType2IDType returns an appropriate IDType for the specified BlockType. +func BlockType2IDType(blockType BlockType) utils.IDType { + switch blockType { + case TypeBoard: + return utils.IDTypeBoard + case TypeCard: + return utils.IDTypeCard + case TypeView: + return utils.IDTypeView + case TypeText, TypeComment: + return utils.IDTypeBlock + } + return utils.IDTypeNone +} + // ErrInvalidBlockType is returned wherever an invalid block type was provided. type ErrInvalidBlockType struct { Type string diff --git a/server/utils/utils.go b/server/utils/utils.go index 70327fa34..9c2db2d04 100644 --- a/server/utils/utils.go +++ b/server/utils/utils.go @@ -4,8 +4,6 @@ import ( "encoding/json" "time" - "github.com/mattermost/focalboard/server/model" - mm_model "github.com/mattermost/mattermost-server/v6/model" ) @@ -31,21 +29,6 @@ func NewID(idType IDType) string { return string(idType) + mm_model.NewId() } -// BlockType2IDType returns an appropriate IDType for the specified BlockType. -func BlockType2IDType(blockType model.BlockType) IDType { - switch blockType { - case model.TypeBoard: - return IDTypeBoard - case model.TypeCard: - return IDTypeCard - case model.TypeView: - return IDTypeView - case model.TypeText, model.TypeComment: - return IDTypeBlock - } - return IDTypeNone -} - // GetMillis is a convenience method to get milliseconds since epoch. func GetMillis() int64 { return mm_model.GetMillis()