diff options
author | 2023-07-07 14:58:53 +0200 | |
---|---|---|
committer | 2023-07-07 14:58:53 +0200 | |
commit | ac564c18624aea229defc38bc1cc516d6c787520 (patch) | |
tree | 00fabbb17f9432bbb8fd9b2de4b185ede40f3f39 /internal/api/util/parsequery.go | |
parent | [docs] Rework backups a bit (#1942) (diff) | |
download | gotosocial-ac564c18624aea229defc38bc1cc516d6c787520.tar.xz |
[bugfix] Reorder web view logic, other small fixes (#1954)
Diffstat (limited to 'internal/api/util/parsequery.go')
-rw-r--r-- | internal/api/util/parsequery.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/api/util/parsequery.go b/internal/api/util/parsequery.go index f5966bca1..59b07f7ee 100644 --- a/internal/api/util/parsequery.go +++ b/internal/api/util/parsequery.go @@ -43,6 +43,11 @@ const ( SearchResolveKey = "resolve" SearchTypeKey = "type" + /* Web endpoint keys */ + + WebUsernameKey = "username" + WebStatusIDKey = "status" + /* Domain block keys */ DomainBlockExportKey = "export" @@ -75,6 +80,14 @@ func ParseLocal(value string, defaultValue bool) (bool, gtserror.WithCode) { return parseBool(value, defaultValue, LocalKey) } +func ParseMaxID(value string, defaultValue string) string { + if value == "" { + return defaultValue + } + + return value +} + func ParseSearchExcludeUnreviewed(value string, defaultValue bool) (bool, gtserror.WithCode) { return parseBool(value, defaultValue, SearchExcludeUnreviewedKey) } @@ -133,6 +146,26 @@ func ParseSearchQuery(value string) (string, gtserror.WithCode) { return value, nil } +func ParseWebUsername(value string) (string, gtserror.WithCode) { + key := WebUsernameKey + + if value == "" { + return "", requiredError(key) + } + + return value, nil +} + +func ParseWebStatusID(value string) (string, gtserror.WithCode) { + key := WebStatusIDKey + + if value == "" { + return "", requiredError(key) + } + + return value, nil +} + /* Internal functions */ |