mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-16 12:33:00 -06:00
[bugfix] self-referencing collection pages for status replies (#2364)
This commit is contained in:
parent
efefdb1323
commit
16275853eb
24 changed files with 611 additions and 427 deletions
|
|
@ -41,6 +41,10 @@ const (
|
|||
SinceIDKey = "since_id"
|
||||
MinIDKey = "min_id"
|
||||
|
||||
/* AP endpoint keys */
|
||||
|
||||
OnlyOtherAccountsKey = "only_other_accounts"
|
||||
|
||||
/* Search keys */
|
||||
|
||||
SearchExcludeUnreviewedKey = "exclude_unreviewed"
|
||||
|
|
@ -66,20 +70,6 @@ const (
|
|||
DomainPermissionImportKey = "import"
|
||||
)
|
||||
|
||||
// parseError returns gtserror.WithCode set to 400 Bad Request, to indicate
|
||||
// to the caller that a key was set to a value that could not be parsed.
|
||||
func parseError(key string, value, defaultValue any, err error) gtserror.WithCode {
|
||||
err = fmt.Errorf("error parsing key %s with value %s as %T: %w", key, value, defaultValue, err)
|
||||
return gtserror.NewErrorBadRequest(err, err.Error())
|
||||
}
|
||||
|
||||
// requiredError returns gtserror.WithCode set to 400 Bad Request, to indicate
|
||||
// to the caller a required key value was not provided, or was empty.
|
||||
func requiredError(key string) gtserror.WithCode {
|
||||
err := fmt.Errorf("required key %s was not set or had empty value", key)
|
||||
return gtserror.NewErrorBadRequest(err, err.Error())
|
||||
}
|
||||
|
||||
/*
|
||||
Parse functions for *OPTIONAL* parameters with default values.
|
||||
*/
|
||||
|
|
@ -129,6 +119,10 @@ func ParseDomainPermissionImport(value string, defaultValue bool) (bool, gtserro
|
|||
return parseBool(value, defaultValue, DomainPermissionImportKey)
|
||||
}
|
||||
|
||||
func ParseOnlyOtherAccounts(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, OnlyOtherAccountsKey)
|
||||
}
|
||||
|
||||
/*
|
||||
Parse functions for *REQUIRED* parameters.
|
||||
*/
|
||||
|
|
@ -248,3 +242,17 @@ func parseInt(value string, defaultValue int, max int, min int, key string) (int
|
|||
|
||||
return i, nil
|
||||
}
|
||||
|
||||
// parseError returns gtserror.WithCode set to 400 Bad Request, to indicate
|
||||
// to the caller that a key was set to a value that could not be parsed.
|
||||
func parseError(key string, value, defaultValue any, err error) gtserror.WithCode {
|
||||
err = fmt.Errorf("error parsing key %s with value %s as %T: %w", key, value, defaultValue, err)
|
||||
return gtserror.NewErrorBadRequest(err, err.Error())
|
||||
}
|
||||
|
||||
// requiredError returns gtserror.WithCode set to 400 Bad Request, to indicate
|
||||
// to the caller a required key value was not provided, or was empty.
|
||||
func requiredError(key string) gtserror.WithCode {
|
||||
err := fmt.Errorf("required key %s was not set or had empty value", key)
|
||||
return gtserror.NewErrorBadRequest(err, err.Error())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue