summaryrefslogtreecommitdiff
path: root/internal/api/util/parsequery.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-07-07 14:58:53 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-07 14:58:53 +0200
commitac564c18624aea229defc38bc1cc516d6c787520 (patch)
tree00fabbb17f9432bbb8fd9b2de4b185ede40f3f39 /internal/api/util/parsequery.go
parent[docs] Rework backups a bit (#1942) (diff)
downloadgotosocial-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.go33
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
*/