diff options
author | 2023-05-25 10:37:38 +0200 | |
---|---|---|
committer | 2023-05-25 10:37:38 +0200 | |
commit | f5c004d67d4ed66b6c6df100afec47174aa14ae0 (patch) | |
tree | 45b72a6e90450d711e10571d844138186fe023c9 /internal/validate | |
parent | [docs] local docs hacking howto (#1816) (diff) | |
download | gotosocial-f5c004d67d4ed66b6c6df100afec47174aa14ae0.tar.xz |
[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
Diffstat (limited to 'internal/validate')
-rw-r--r-- | internal/validate/formvalidation.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/validate/formvalidation.go b/internal/validate/formvalidation.go index 20d4aa782..f9328dc1f 100644 --- a/internal/validate/formvalidation.go +++ b/internal/validate/formvalidation.go @@ -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'") + } +} |