From 9cadc764b389df970c767608e7a061f3bd777dfa Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:22:05 +0100 Subject: [feature] Add experimental `instance-federation-spam-filter` option (#2685) * [chore] Move `visibility` to `filter/visibility` * [feature] Add experimental instance-federation-spam-filter option --- internal/gtserror/error.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'internal/gtserror/error.go') diff --git a/internal/gtserror/error.go b/internal/gtserror/error.go index 9fd9812dc..dc4c5a504 100644 --- a/internal/gtserror/error.go +++ b/internal/gtserror/error.go @@ -37,6 +37,8 @@ const ( wrongTypeKey smtpKey malformedKey + notRelevantKey + spamKey ) // IsUnretrievable indicates that a call to retrieve a resource @@ -127,3 +129,30 @@ func IsMalformed(err error) bool { func SetMalformed(err error) error { return errors.WithValue(err, malformedKey, struct{}{}) } + +// IsNotRelevant checks error for a stored "notRelevant" flag. +// This error is used when determining whether or not to store +// + process an incoming AP message. +func IsNotRelevant(err error) bool { + _, ok := errors.Value(err, notRelevantKey).(struct{}) + return ok +} + +// SetNotRelevant will wrap the given error to store a "notRelevant" flag, +// returning wrapped error. See IsNotRelevant() for example use-cases. +func SetNotRelevant(err error) error { + return errors.WithValue(err, notRelevantKey, struct{}{}) +} + +// IsSpam checks error for a stored "spam" flag. This error is used when +// determining whether or not to store + process an incoming AP message. +func IsSpam(err error) bool { + _, ok := errors.Value(err, spamKey).(struct{}) + return ok +} + +// SetSpam will wrap the given error to store a "spam" flag, +// returning wrapped error. See IsSpam() for example use-cases. +func SetSpam(err error) error { + return errors.WithValue(err, spamKey, struct{}{}) +} -- cgit v1.2.3