mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[bugfix] fix media limit reader check (#3363)
* return nicer errors for frontend when media / emoji upload limit reached * fix reader limit check * add code comment
This commit is contained in:
@@ -40,8 +40,22 @@ const (
|
||||
notRelevantKey
|
||||
spamKey
|
||||
notPermittedKey
|
||||
limitReachedKey
|
||||
)
|
||||
|
||||
// LimitReached indicates that this error was caused by
|
||||
// some kind of limit being reached, e.g. media upload limit.
|
||||
func LimitReached(err error) bool {
|
||||
_, ok := errors.Value(err, limitReachedKey).(struct{})
|
||||
return ok
|
||||
}
|
||||
|
||||
// SetLimitReached will wrap the given error to store a "limit reached"
|
||||
// flag, returning wrapped error. See LimitReached() for example use-cases.
|
||||
func SetLimitReached(err error) error {
|
||||
return errors.WithValue(err, limitReachedKey, struct{}{})
|
||||
}
|
||||
|
||||
// IsUnretrievable indicates that a call to retrieve a resource
|
||||
// (account, status, attachment, etc) could not be fulfilled, either
|
||||
// because it was not found locally, or because some prerequisite
|
||||
|
Reference in New Issue
Block a user