summaryrefslogtreecommitdiff
path: root/internal/validate/formvalidation.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-11 13:19:06 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-11 13:19:06 +0200
commit9dc2255a8fab8ef0bc4b9f417c6131e4c468cb9c (patch)
treeae528bf14a3475bbea264ff26e5ffded3dfadf8a /internal/validate/formvalidation.go
parentTest both dbs (#205) (diff)
downloadgotosocial-9dc2255a8fab8ef0bc4b9f417c6131e4c468cb9c.tar.xz
kim is a reply guy (#208)
* bun debug * bun trace logging hooks * more tests * fix up some stuffffff * drop the frontend cache until a proper fix is made * go fmt
Diffstat (limited to 'internal/validate/formvalidation.go')
-rw-r--r--internal/validate/formvalidation.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/validate/formvalidation.go b/internal/validate/formvalidation.go
index 9f61578e7..7215c8fcd 100644
--- a/internal/validate/formvalidation.go
+++ b/internal/validate/formvalidation.go
@@ -23,6 +23,7 @@ import (
"fmt"
"net/mail"
+ apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/regexes"
pwv "github.com/wagslane/go-password-validator"
"golang.org/x/text/language"
@@ -126,8 +127,14 @@ func Note(note string) error {
// Privacy checks that the desired privacy setting is valid
func Privacy(privacy string) error {
- // TODO: add some validation logic here -- length, characters, etc
- return nil
+ if privacy == "" {
+ return fmt.Errorf("empty string for privacy not allowed")
+ }
+ switch apimodel.Visibility(privacy) {
+ case apimodel.VisibilityDirect, apimodel.VisibilityMutualsOnly, apimodel.VisibilityPrivate, apimodel.VisibilityPublic, apimodel.VisibilityUnlisted:
+ return nil
+ }
+ return fmt.Errorf("privacy %s was not recognized", privacy)
}
// EmojiShortcode just runs the given shortcode through the regular expression