mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:22:24 -05:00
[feature] Add experimental instance-federation-spam-filter option (#2685)
* [chore] Move `visibility` to `filter/visibility` * [feature] Add experimental instance-federation-spam-filter option
This commit is contained in:
parent
87e8cca3ae
commit
9cadc764b3
80 changed files with 1638 additions and 137 deletions
|
|
@ -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{}{})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue