diff options
Diffstat (limited to 'internal/gtserror/error.go')
-rw-r--r-- | internal/gtserror/error.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/internal/gtserror/error.go b/internal/gtserror/error.go index dc4c5a504..a39b5475c 100644 --- a/internal/gtserror/error.go +++ b/internal/gtserror/error.go @@ -39,13 +39,13 @@ const ( malformedKey notRelevantKey spamKey + notPermittedKey ) // 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 remote resource call failed, making it impossible -// to return the item. +// (account, status, attachment, etc) could not be fulfilled, either +// because it was not found locally, or because some prerequisite +// remote resource call failed, making it impossible to return it. func IsUnretrievable(err error) bool { _, ok := errors.Value(err, unrtrvableKey).(struct{}) return ok @@ -57,6 +57,21 @@ func SetUnretrievable(err error) error { return errors.WithValue(err, unrtrvableKey, struct{}{}) } +// NotPermitted indicates that some call failed due to failed permission +// or acceptibility checks. For example an attempt to dereference remote +// status in which the status author does not have permission to reply +// to the status it is intended to be replying to. +func NotPermitted(err error) bool { + _, ok := errors.Value(err, notPermittedKey).(struct{}) + return ok +} + +// SetNotPermitted will wrap the given error to store a "not permitted" +// flag, returning wrapped error. See NotPermitted() for example use-cases. +func SetNotPermitted(err error) error { + return errors.WithValue(err, notPermittedKey, struct{}{}) +} + // IsWrongType checks error for a stored "wrong type" flag. // Wrong type indicates that an ActivityPub URI returned a // type we weren't expecting. For example: |