filter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const DensityFilterName = "DensityFilter"
View Source
const EventTypeFilterName = "EventTypeFilter"
View Source
const HellbanPostfilterName = "HellbanPostfilter"
View Source
const HellbanPrefilterName = "HellbanPrefilter"
View Source
const KeywordFilterName = "KeywordFilter"
View Source
const LengthFilterName = "LengthFilter"
View Source
const ManyAtsFilterName = "ManyAtsFilter"
View Source
const MediaFilterName = "MediaFilter"
View Source
const MediaScanningFilterName = "MediaScanningFilter"
View Source
const MentionsFilterName = "MentionsFilter"
View Source
const MjolnirFilterName = "MjolnirFilter"
View Source
const OpenAIFilterName = "OpenAIFilter"
View Source
const SenderFilterName = "SenderFilter"
View Source
const StickyEventsFilterName = "StickyEventsFilter"
View Source
const TrimLengthFilterName = "TrimLengthFilter"
View Source
const UntrustedMediaFilterName = "UntrustedMediaFilter"

Variables

View Source
var InvalidMediaUrlError = errors.New("invalid media url")

Functions

This section is empty.

Types

type AIProvider

type AIProvider interface {
	CheckEvent(ctx context.Context, cnf *aiFilterConfig, input *Input) ([]classification.Classification, error)
}

type CanBeInstanced

type CanBeInstanced interface {
	// MakeFor - Creates a long-lived Instanced for the provided Set. If an error occurred, the Instanced will
	// be nil.
	MakeFor(set *Set) (Instanced, error)
}

CanBeInstanced - The base filter type, registered at compile/run time and used by Sets to create a long-lived Instanced instance.

type DensityFilter

type DensityFilter struct {
}

func (*DensityFilter) MakeFor

func (d *DensityFilter) MakeFor(set *Set) (Instanced, error)

type EventTypeFilter

type EventTypeFilter struct {
}

func (*EventTypeFilter) MakeFor

func (e *EventTypeFilter) MakeFor(set *Set) (Instanced, error)

type HellbanPostfilter

type HellbanPostfilter struct {
}

func (*HellbanPostfilter) MakeFor

func (h *HellbanPostfilter) MakeFor(set *Set) (Instanced, error)

type HellbanPrefilter

type HellbanPrefilter struct {
}

func (*HellbanPrefilter) MakeFor

func (h *HellbanPrefilter) MakeFor(set *Set) (Instanced, error)

type Input

type Input struct {
	// The event to process/check.
	Event gomatrixserverlib.PDU

	// The confidence.Vectors so far. Note that the first set group will receive a classification.Spam vector of 0.5
	IncrementalConfidenceVectors confidence.Vectors

	// Extracted media items from the event.
	Medias []*Media
	// contains filtered or unexported fields
}

Input - A filter input.

type Instanced

type Instanced interface {
	// Name - The name of the filter for logging and metrics.
	Name() string

	// CheckEvent - Processes the given event, returning classifications about it. If an error occurred, the classifications
	// array will be nil/empty.
	CheckEvent(ctx context.Context, input *Input) ([]classification.Classification, error)
}

Instanced - A Set-specific filter.

type InstancedDensityFilter

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

func (*InstancedDensityFilter) CheckEvent

func (*InstancedDensityFilter) Name

func (f *InstancedDensityFilter) Name() string

type InstancedEventTypeFilter

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

func (*InstancedEventTypeFilter) CheckEvent

func (*InstancedEventTypeFilter) Name

func (f *InstancedEventTypeFilter) Name() string

type InstancedHellbanFilter

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

func (*InstancedHellbanFilter) CheckEvent

func (*InstancedHellbanFilter) Close

func (f *InstancedHellbanFilter) Close() error

func (*InstancedHellbanFilter) Name

func (f *InstancedHellbanFilter) Name() string

type InstancedKeywordFilter

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

func (*InstancedKeywordFilter) CheckEvent

func (*InstancedKeywordFilter) Name

func (f *InstancedKeywordFilter) Name() string

type InstancedLengthFilter

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

func (*InstancedLengthFilter) CheckEvent

func (*InstancedLengthFilter) Name

func (f *InstancedLengthFilter) Name() string

type InstancedManyAtsFilter

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

func (*InstancedManyAtsFilter) CheckEvent

func (*InstancedManyAtsFilter) Name

func (f *InstancedManyAtsFilter) Name() string

type InstancedMediaFilter

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

func (*InstancedMediaFilter) CheckEvent

func (*InstancedMediaFilter) Name

func (f *InstancedMediaFilter) Name() string

type InstancedMediaScanningFilter

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

func (*InstancedMediaScanningFilter) CheckEvent

func (*InstancedMediaScanningFilter) Name

type InstancedMentionsFilter

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

func (*InstancedMentionsFilter) CheckEvent

func (*InstancedMentionsFilter) Name

func (f *InstancedMentionsFilter) Name() string

type InstancedMjolnirFilter

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

func (*InstancedMjolnirFilter) CheckEvent

func (*InstancedMjolnirFilter) Name

func (f *InstancedMjolnirFilter) Name() string

type InstancedOpenAIFilter

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

func (*InstancedOpenAIFilter) CheckEvent

func (*InstancedOpenAIFilter) Name

func (f *InstancedOpenAIFilter) Name() string

type InstancedSenderFilter

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

func (*InstancedSenderFilter) CheckEvent

func (*InstancedSenderFilter) Name

func (f *InstancedSenderFilter) Name() string

type InstancedStickyEventsFilter

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

func (*InstancedStickyEventsFilter) CheckEvent

func (*InstancedStickyEventsFilter) Name

type InstancedTrimLengthFilter

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

func (*InstancedTrimLengthFilter) CheckEvent

func (*InstancedTrimLengthFilter) Name

type InstancedUntrustedMediaFilter

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

func (*InstancedUntrustedMediaFilter) CheckEvent

func (*InstancedUntrustedMediaFilter) Name

type KeywordFilter

type KeywordFilter struct {
}

func (*KeywordFilter) MakeFor

func (k *KeywordFilter) MakeFor(set *Set) (Instanced, error)

type LengthFilter

type LengthFilter struct {
}

func (*LengthFilter) MakeFor

func (l *LengthFilter) MakeFor(set *Set) (Instanced, error)

type ManyAtsFilter

type ManyAtsFilter struct {
}

func (*ManyAtsFilter) MakeFor

func (m *ManyAtsFilter) MakeFor(set *Set) (Instanced, error)

type Media

type Media struct {
	Origin  string
	MediaId string
	// contains filtered or unexported fields
}

Media - A piece of media that was extracted from an event.

func NewMedia

func NewMedia(mediaUrl string, downloader media.Downloader) (*Media, error)

NewMedia - Creates a new Media instance from the given URL. Returns an InvalidMediaUrlError if the URL is invalid or not an MXC URL.

func (*Media) Download

func (m *Media) Download() ([]byte, error)

func (*Media) String

func (m *Media) String() string

type MediaFilter

type MediaFilter struct {
}

func (*MediaFilter) MakeFor

func (m *MediaFilter) MakeFor(set *Set) (Instanced, error)

type MediaScanningFilter

type MediaScanningFilter struct {
}

func (*MediaScanningFilter) MakeFor

func (m *MediaScanningFilter) MakeFor(set *Set) (Instanced, error)

type MentionsFilter

type MentionsFilter struct {
}

func (*MentionsFilter) MakeFor

func (m *MentionsFilter) MakeFor(set *Set) (Instanced, error)

type MjolnirFilter

type MjolnirFilter struct {
}

func (*MjolnirFilter) MakeFor

func (m *MjolnirFilter) MakeFor(set *Set) (Instanced, error)

type OpenAIFilter

type OpenAIFilter struct {
}

func (*OpenAIFilter) MakeFor

func (o *OpenAIFilter) MakeFor(set *Set) (Instanced, error)

type OpenAIModerationModelAIProvider

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

func NewOpenAIModerationModelAIProvider

func NewOpenAIModerationModelAIProvider(instanceConfig *config.InstanceConfig) *OpenAIModerationModelAIProvider

func (*OpenAIModerationModelAIProvider) CheckEvent

func (p *OpenAIModerationModelAIProvider) CheckEvent(ctx context.Context, cnf *aiFilterConfig, input *Input) ([]classification.Classification, error)

type SenderFilter

type SenderFilter struct {
}

func (*SenderFilter) MakeFor

func (s *SenderFilter) MakeFor(set *Set) (Instanced, error)

type Set

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

func NewSet

func NewSet(config *SetConfig, storage storage.PersistentStorage, pubsub pubsub.Client, queue *audit.Queue, contentScanner content.Scanner) (*Set, error)

func (*Set) CheckEvent

func (s *Set) CheckEvent(ctx context.Context, event gomatrixserverlib.PDU, mediaDownloader media.Downloader) (confidence.Vectors, error)

CheckEvent - Checks an event over all of the set groups in order. If a set group errors, execution stops there. Note: the mediaDownloader may be nil to prevent parsing and downloading of media. This should only be done in test environments.

func (*Set) Close

func (s *Set) Close() error

func (*Set) GetStorage

func (s *Set) GetStorage() storage.PersistentStorage

GetStorage - Accessor to the underlying PersistentStorage

func (*Set) IsSpamResponse

func (s *Set) IsSpamResponse(ctx context.Context, vecs confidence.Vectors) bool

type SetConfig

type SetConfig struct {
	// Filters are organized into Groups for execution and processing.
	Groups          []*SetGroupConfig
	CommunityConfig *config.CommunityConfig
	InstanceConfig  *config.InstanceConfig
	CommunityId     string
}

type SetGroupConfig

type SetGroupConfig struct {
	// The filter names this group enables. All filters within a group are executed concurrently.
	EnabledNames []string

	// The minimum vector value for classification.Spam required for this set group to process events.
	// Note: The first set group will receive a classification.Spam vector value of 0.5
	MinimumSpamVectorValue float64

	// The maximum vector value for classification.Spam allowed for this set group to process events.
	MaximumSpamVectorValue float64
}

type StickyEventsFilter

type StickyEventsFilter struct {
}

func (*StickyEventsFilter) MakeFor

func (s *StickyEventsFilter) MakeFor(set *Set) (Instanced, error)

type TrimLengthFilter

type TrimLengthFilter struct {
}

func (*TrimLengthFilter) MakeFor

func (t *TrimLengthFilter) MakeFor(set *Set) (Instanced, error)

type UntrustedMediaFilter

type UntrustedMediaFilter struct {
}

func (*UntrustedMediaFilter) MakeFor

func (m *UntrustedMediaFilter) MakeFor(set *Set) (Instanced, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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