filter

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 39 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 KeywordTemplateFilterName = "KeywordTemplateFilter"
View Source
const LengthFilterName = "LengthFilter"
View Source
const LinkFilterName = "LinkFilter"
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 OpenAIOmniFilterName = "OpenAIOmniFilter"
View Source
const SenderFilterName = "SenderFilter"
View Source
const StickyEventsFilterName = "StickyEventsFilter"
View Source
const TrimLengthFilterName = "TrimLengthFilter"
View Source
const UnsafeSigningKeyFilterName = "UnsafeSigningKeyFilter"
View Source
const UntrustedMediaFilterName = "UntrustedMediaFilter"

Variables

This section is empty.

Functions

func UnsafeSigningKeys added in v1.2.0

func UnsafeSigningKeys() []ed25519.PublicKey

Types

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 EventInput added in v1.2.0

type EventInput 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.Item
	// contains filtered or unexported fields
}

EventInput - An event with context to be provided to an InstancedEventFilter.

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 Instanced

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

Instanced - A Set-specific filter.

type InstancedAIExecutorFilter added in v1.1.0

type InstancedAIExecutorFilter[ConfigT any] struct {
	// contains filtered or unexported fields
}

func NewInstancedAIExecutorFilter added in v1.1.0

func NewInstancedAIExecutorFilter[ConfigT any](name string, set *Set, config ConfigT, aiProvider ai.Provider[ConfigT], inRoomIds []string) *InstancedAIExecutorFilter[ConfigT]

func (*InstancedAIExecutorFilter[ConfigT]) CheckEvent added in v1.1.0

func (f *InstancedAIExecutorFilter[ConfigT]) CheckEvent(ctx context.Context, input *EventInput) ([]classification.Classification, error)

func (*InstancedAIExecutorFilter[ConfigT]) Name added in v1.1.0

func (f *InstancedAIExecutorFilter[ConfigT]) Name() string

type InstancedDensityFilter

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

func (*InstancedDensityFilter) CheckEvent

func (*InstancedDensityFilter) CheckText added in v1.2.0

func (*InstancedDensityFilter) Name

func (f *InstancedDensityFilter) Name() string

type InstancedEventFilter added in v1.2.0

type InstancedEventFilter interface {
	Instanced // parent type

	// 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 *EventInput) ([]classification.Classification, error)
}

InstancedEventFilter - A filter which processes events.

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) CheckText added in v1.2.0

func (*InstancedKeywordFilter) Name

func (f *InstancedKeywordFilter) Name() string

type InstancedKeywordTemplateFilter added in v1.1.0

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

func (*InstancedKeywordTemplateFilter) CheckEvent added in v1.1.0

func (*InstancedKeywordTemplateFilter) CheckText added in v1.2.0

func (*InstancedKeywordTemplateFilter) Name added in v1.1.0

type InstancedLengthFilter

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

func (*InstancedLengthFilter) CheckEvent

func (*InstancedLengthFilter) CheckText added in v1.2.0

func (*InstancedLengthFilter) Name

func (f *InstancedLengthFilter) Name() string

type InstancedLinkFilter added in v1.2.0

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

func (*InstancedLinkFilter) CheckEvent added in v1.2.0

func (*InstancedLinkFilter) CheckText added in v1.2.0

func (*InstancedLinkFilter) Name added in v1.2.0

func (f *InstancedLinkFilter) Name() string

type InstancedManyAtsFilter

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

func (*InstancedManyAtsFilter) CheckEvent

func (*InstancedManyAtsFilter) CheckText added in v1.2.0

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 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 InstancedTextFilter added in v1.2.0

type InstancedTextFilter interface {
	Instanced // parent type

	// CheckText - Processes the given text, returning classifications about it. If an error occurred, the classifications
	// array will be nil/empty. The input text string is assumed to be user-generated (message body, search query, etc)
	// rather than structured (JSON, CSV, etc).
	CheckText(ctx context.Context, input string) ([]classification.Classification, error)
}

type InstancedTrimLengthFilter

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

func (*InstancedTrimLengthFilter) CheckEvent

func (*InstancedTrimLengthFilter) CheckText added in v1.2.0

func (*InstancedTrimLengthFilter) Name

type InstancedUnsafeSigningKeyFilter added in v1.2.0

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

func (*InstancedUnsafeSigningKeyFilter) CheckEvent added in v1.2.0

func (*InstancedUnsafeSigningKeyFilter) Name added in v1.2.0

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 KeywordTemplateFilter added in v1.1.0

type KeywordTemplateFilter struct {
}

func (*KeywordTemplateFilter) MakeFor added in v1.1.0

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

type LengthFilter

type LengthFilter struct {
}

func (*LengthFilter) MakeFor

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

type LinkFilter added in v1.2.0

type LinkFilter struct{}

LinkFilter is a filter that checks for URLs in the event content. It's configured with a deny list and an allow list. Matches against the deny list win.

func (*LinkFilter) MakeFor added in v1.2.0

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

type ManyAtsFilter

type ManyAtsFilter struct {
}

func (*ManyAtsFilter) MakeFor

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

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 OpenAIOmniFilter added in v1.1.0

type OpenAIOmniFilter struct {
}

func (*OpenAIOmniFilter) MakeFor added in v1.1.0

func (o *OpenAIOmniFilter) MakeFor(set *Set) (Instanced, 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) CheckText added in v1.2.0

func (s *Set) CheckText(ctx context.Context, text string) (confidence.Vectors, error)

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 UnsafeSigningKeyFilter added in v1.2.0

type UnsafeSigningKeyFilter struct {
}

func (*UnsafeSigningKeyFilter) MakeFor added in v1.2.0

func (u *UnsafeSigningKeyFilter) 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