[bugfix] Reorder web view logic, other small fixes (#1954)

This commit is contained in:
tobi 2023-07-07 14:58:53 +02:00 committed by GitHub
commit ac564c1862
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 375 additions and 182 deletions

View file

@ -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
*/