diff options
author | 2024-06-18 18:18:00 +0200 | |
---|---|---|
committer | 2024-06-18 18:18:00 +0200 | |
commit | d2b3d37724a999d4cc78c46157593267e29d184e (patch) | |
tree | ac72be127d8adb80bbd756ad970ae14df7b5618f /internal/api/util/parsequery.go | |
parent | [feature] Implement types[] param for notifications (#3009) (diff) | |
download | gotosocial-d2b3d37724a999d4cc78c46157593267e29d184e.tar.xz |
[feature/frontend] Reports frontend v2 (#3022)
* use apiutil + paging in admin processor+handlers
* we're making it happen
* fix little whoopsie
* styling for report list
* don't youuuu forget about meee don't don't don't don't
* last bits
* sanitize content before showing in report statuses
* update report docs
Diffstat (limited to 'internal/api/util/parsequery.go')
-rw-r--r-- | internal/api/util/parsequery.go | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/internal/api/util/parsequery.go b/internal/api/util/parsequery.go index 5210735a1..90cc30e6f 100644 --- a/internal/api/util/parsequery.go +++ b/internal/api/util/parsequery.go @@ -34,13 +34,16 @@ const ( /* Common keys */ - IDKey = "id" - LimitKey = "limit" - LocalKey = "local" - MaxIDKey = "max_id" - SinceIDKey = "since_id" - MinIDKey = "min_id" - UsernameKey = "username" + IDKey = "id" + LimitKey = "limit" + LocalKey = "local" + MaxIDKey = "max_id" + SinceIDKey = "since_id" + MinIDKey = "min_id" + UsernameKey = "username" + AccountIDKey = "account_id" + TargetAccountIDKey = "target_account_id" + ResolvedKey = "resolved" /* AP endpoint keys */ @@ -55,7 +58,6 @@ const ( SearchQueryKey = "q" SearchResolveKey = "resolve" SearchTypeKey = "type" - SearchAccountIDKey = "account_id" /* Tag keys */ @@ -132,6 +134,10 @@ func ParseLocal(value string, defaultValue bool) (bool, gtserror.WithCode) { return parseBool(value, defaultValue, LocalKey) } +func ParseResolved(value string, defaultValue *bool) (*bool, gtserror.WithCode) { + return parseBoolPtr(value, defaultValue, ResolvedKey) +} + func ParseSearchExcludeUnreviewed(value string, defaultValue bool) (bool, gtserror.WithCode) { return parseBool(value, defaultValue, SearchExcludeUnreviewedKey) } @@ -289,6 +295,19 @@ func parseBool(value string, defaultValue bool, key string) (bool, gtserror.With return i, nil } +func parseBoolPtr(value string, defaultValue *bool, key string) (*bool, gtserror.WithCode) { + if value == "" { + return defaultValue, nil + } + + i, err := strconv.ParseBool(value) + if err != nil { + return defaultValue, parseError(key, value, defaultValue, err) + } + + return &i, nil +} + func parseInt(value string, defaultValue int, max int, min int, key string) (int, gtserror.WithCode) { if value == "" { return defaultValue, nil |