mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Add List functionality (#1802)
* start working on lists * further list work * test list db functions nicely * more work on lists * peepoopeepoo * poke * start list timeline func * we're getting there lads * couldn't be me working on stuff... could it? * hook up handlers * fiddling * weeee * woah * screaming, pissing * fix streaming being a whiny baby * lint, small test fix, swagger * tidying up, testing * fucked! by the linter * move timelines to state like a boss * add timeline start to tests using state * invalidate lists
This commit is contained in:
@ -45,6 +45,7 @@ const (
|
||||
maximumEmojiCategoryLength = 64
|
||||
maximumProfileFieldLength = 255
|
||||
maximumProfileFields = 6
|
||||
maximumListTitleLength = 200
|
||||
)
|
||||
|
||||
// NewPassword returns an error if the given password is not sufficiently strong, or nil if it's ok.
|
||||
@ -257,3 +258,28 @@ func ProfileFields(fields []*gtsmodel.Field) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListTitle validates the title of a new or updated List.
|
||||
func ListTitle(title string) error {
|
||||
if title == "" {
|
||||
return fmt.Errorf("list title must be provided, and must be no more than %d chars", maximumListTitleLength)
|
||||
}
|
||||
|
||||
if length := len([]rune(title)); length > maximumListTitleLength {
|
||||
return fmt.Errorf("list title length must be no more than %d chars, provided title was %d chars", maximumListTitleLength, length)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListRepliesPolicy validates the replies_policy of a new or updated list.
|
||||
func ListRepliesPolicy(repliesPolicy gtsmodel.RepliesPolicy) error {
|
||||
switch repliesPolicy {
|
||||
case "", gtsmodel.RepliesPolicyFollowed, gtsmodel.RepliesPolicyList, gtsmodel.RepliesPolicyNone:
|
||||
// No problem.
|
||||
return nil
|
||||
default:
|
||||
// Uh oh.
|
||||
return fmt.Errorf("list replies_policy must be either empty or one of 'followed', 'list', 'none'")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user