spam

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter packages logic for checking whether given statuses should be considered spam.

func NewFilter

func NewFilter(state *state.State) *Filter

NewFilter returns a new spam Filter that will use the provided state.

func (*Filter) StatusableOK

func (f *Filter) StatusableOK(
	ctx context.Context,
	receiver *gtsmodel.Account,
	requester *gtsmodel.Account,
	statusable ap.Statusable,
) error

StatusableOK returns no error if the given statusable looks OK, ie., relevant to the receiver, and not spam.

This should only be used for Creates of statusables, NOT Announces!

If the statusable does not pass relevancy or spam checks, either a Spam or NotRelevant error will be returned. Callers should use gtserror.IsSpam() and gtserror.IsNotRelevant() to check for this.

If the returned error is not nil, but neither Spam or NotRelevant, then it's an actual database error.

The decision is made based on the following heuristics, in order:

  1. Receiver follow requester. Return nil.
  2. Statusable doesn't mention receiver. Return NotRelevant.

If instance-federation-spam-filter = false, then return nil now. Otherwise check:

  1. Receiver is locked and is followed by requester. Return nil.
  2. Five or more people are mentioned. Return Spam.
  3. Receiver follow (requests) a mentioned account. Return nil.
  4. Statusable has a media attachment. Return Spam.
  5. Statusable contains non-mention, non-hashtag links. Return Spam.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL