model

package
v0.0.0-...-536f513 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlocklistService

type BlocklistService interface {
	ByID(matrixID string) bool
	ByServer(server string) bool
}

type Config

type Config struct {
	Port      string           `yaml:"port"`
	SentryDSN string           `yaml:"sentry_dsn"`
	Public    *ConfigPublic    `yaml:"public"`
	Matrix    *ConfigMatrix    `yaml:"matrix"`
	Search    *ConfigSearch    `yaml:"search"`
	Path      *ConfigPaths     `yaml:"path"`
	Batch     *ConfigBatch     `yaml:"batch"`
	Auth      *ConfigAuth      `yaml:"auth"`
	Cron      *ConfigCron      `yaml:"cron"`
	Cache     *ConfigCache     `yaml:"cache"`
	Workers   *ConfigWorkers   `yaml:"workers"`
	Webhooks  *ConfigWebhooks  `yaml:"webhooks"`
	Email     *ConfigEmail     `yaml:"email"`
	Languages []string         `yaml:"languages"`
	Servers   []string         `yaml:"servers"`
	Blocklist *ConfigBlocklist `yaml:"blocklist"`
}

Config is MRS configuration model

type ConfigAuth

type ConfigAuth struct {
	Admin      echobasicauth.Auth `yaml:"admin"`
	Metrics    echobasicauth.Auth `yaml:"metrics"`
	Discovery  echobasicauth.Auth `yaml:"discovery"`
	Moderation echobasicauth.Auth `yaml:"moderation"`
}

ConfigAuth - auth-related configuration

type ConfigBatch

type ConfigBatch struct {
	Rooms int `yaml:"rooms"`
}

ConfigBatch - batches related configuration

type ConfigBlocklist

type ConfigBlocklist struct {
	Servers []string `json:"servers"`
	Queries []string `json:"queries"`
}

ConfigBlocklist - blocklist related configuration

type ConfigCache

type ConfigCache struct {
	MaxAge       int              `yaml:"max_age"`
	MaxAgeSearch int              `yaml:"max_age_search"`
	Bunny        ConfigCacheBunny `yaml:"bunny"`
}

ConfigCache - cache-related configuration

type ConfigCacheBunny

type ConfigCacheBunny struct {
	URL string `yaml:"url"`
	Key string `yaml:"key"`
}

ConfigCacheBunny BunnyCDN cache purging config

type ConfigCron

type ConfigCron struct {
	Discovery string `yaml:"discovery"`
	Parsing   string `yaml:"parsing"`
	Indexing  string `yaml:"indexing"`
	Full      string `yaml:"full"`
}

ConfigCron - cronjobs config

type ConfigEmail

type ConfigEmail struct {
	Postmark   ConfigEmailPostmark  `yaml:"postmark"`
	Moderation string               `yaml:"moderation"`
	Templates  ConfigEmailTemplates `yaml:"templates"`
}

ConfigEmail - email related configuration

type ConfigEmailPostmark

type ConfigEmailPostmark struct {
	Token  string                  `yaml:"server_token"`
	Report ConfigEmailPostmarkType `yaml:"report"`
}

ConfigEmailPostmark is Postmark config

type ConfigEmailPostmarkType

type ConfigEmailPostmarkType struct {
	Stream string `yaml:"message_stream"`
	From   string `yaml:"from"`
}

ConfigEmailPostmarkType is postmark config for specific email type

type ConfigEmailTemplate

type ConfigEmailTemplate struct {
	Subject string `yaml:"subject"`
	Body    string `yaml:"body"`
}

ConfigEmailTemplate - email template config

type ConfigEmailTemplates

type ConfigEmailTemplates struct {
	Report ConfigEmailTemplate `yaml:"report"`
}

ConfigEmailTemplates - email temaplates config

type ConfigMatrix

type ConfigMatrix struct {
	ServerName string            `yaml:"server_name"`
	Support    *msc1929.Response `yaml:"support"`
	Keys       []string          `yaml:"keys"`
	OldKeys    []string          `yaml:"old_keys"`
}

ConfigMatrix - matrix server config

type ConfigPaths

type ConfigPaths struct {
	Index string `yaml:"index"`
	Data  string `yaml:"data"`
}

ConfigPaths - paths configuration

type ConfigPublic

type ConfigPublic struct {
	Name string `yaml:"name"`
	UI   string `yaml:"ui"`
	API  string `yaml:"api"`
}

ConfigPublic - instance public information

type ConfigSearch

type ConfigSearch struct {
	Defaults ConfigSearchDefaults `yaml:"defaults"`
}

ConfigSearch - search-related configuration

type ConfigSearchDefaults

type ConfigSearchDefaults struct {
	Limit  int    `yaml:"limit"`
	Offset int    `yaml:"offset"`
	SortBy string `yaml:"sort_by"`
}

ConfigSearchDefaults default params

type ConfigWebhooks

type ConfigWebhooks struct {
	Moderation string `json:"moderation"`
	Stats      string `json:"stats"`
}

ConfigWebhooks - webhooks related config

type ConfigWorkers

type ConfigWorkers struct {
	Discovery int `yaml:"discovery"`
	Parsing   int `yaml:"parsing"`
}

ConfigWorkers - workers related configuration

type Entry

type Entry struct {
	ID            string `json:"id" yaml:"id"`
	Type          string `json:"type"`
	Alias         string `json:"alias" yaml:"alias"`
	Name          string `json:"name" yaml:"name"`
	Topic         string `json:"topic" yaml:"topic"`
	Avatar        string `json:"avatar" yaml:"avatar"`
	AvatarURL     string `json:"avatar_url" yaml:"avatar_url"`
	Server        string `json:"server" yaml:"server"`
	Members       int    `json:"members" yaml:"members"`
	Language      string `json:"language" yaml:"language"`
	RoomType      string `json:"room_type" yaml:"room_type"`
	JoinRule      string `json:"join_rule" yaml:"join_rule"`
	GuestJoinable bool   `json:"guest_can_join" yaml:"guest_can_join"`
	WorldReadable bool   `json:"world_readable" yaml:"world_readable"`
}

Entry represents indexable and/or indexed matrix room

func (*Entry) IsBlocked

func (r *Entry) IsBlocked(block BlocklistService) bool

IsBlocked checks if room's server is blocked

func (*Entry) RoomDirectory

func (r *Entry) RoomDirectory() *RoomDirectoryRoom

RoomDirectory converts processed matrix room intro room directory's room

type IndexStats

type IndexStats struct {
	Servers   IndexStatsServers `json:"servers"`
	Rooms     IndexStatsRooms   `json:"rooms"`
	Discovery IndexStatsTime    `json:"discovery"`
	Parsing   IndexStatsTime    `json:"parsing"`
	Indexing  IndexStatsTime    `json:"indexing"`
}

IndexStats structure

type IndexStatsRooms

type IndexStatsRooms struct {
	Indexed  int `json:"indexed"`
	Parsed   int `json:"parsed"`
	Banned   int `json:"banned"`
	Reported int `json:"reported"`
}

IndexStatsRooms structure

type IndexStatsServers

type IndexStatsServers struct {
	Online    int `json:"online"`
	Indexable int `json:"indexable"`
	Blocked   int `json:"blocked"`
}

IndexStatsServers structure

type IndexStatsTime

type IndexStatsTime struct {
	StartedAt  time.Time `json:"started_at"`
	FinishedAt time.Time `json:"finished_at"`
}

IndexStatsTime structure

type Key

type Key struct {
	ID      string
	Private ed25519.PrivateKey
	Public  string
}

Key is ed25519 key

func KeyFrom

func KeyFrom(str string) (*Key, error)

KeyFrom parses key from string

type MatrixError

type MatrixError struct {
	HTTP    string `json:"-"`       // HTTP Status e.g., 401 Unauthorized
	Code    string `json:"errcode"` // Matrix error code, e.g M_UNAUTHORIZED
	Message string `json:"error"`   // Matrix error message
}

MatrixError model

func (MatrixError) Error

func (e MatrixError) Error() string

Error string

type MatrixRoom

type MatrixRoom struct {
	ID            string `json:"room_id"`
	Name          string `json:"name"`
	Topic         string `json:"topic"`
	Alias         string `json:"canonical_alias"`
	Avatar        string `json:"avatar_url"`
	Members       int    `json:"num_joined_members"`
	RoomType      string `json:"room_type"`
	JoinRule      string `json:"join_rule"`
	GuestJoinable bool   `json:"guest_can_join"`
	WorldReadable bool   `json:"world_readable"`

	// Parsed (custom) fields
	Server    string    `json:"server"`
	Language  string    `json:"language"`
	AvatarURL string    `json:"avatar_url_http"`
	ParsedAt  time.Time `json:"parsed_at"`
}

MatrixRoom from matrix client-server API

func (*MatrixRoom) DirectoryEntry

func (r *MatrixRoom) DirectoryEntry() *RoomDirectoryRoom

DirectoryEntry converts matrix room into matrix room directory entry

func (*MatrixRoom) Entry

func (r *MatrixRoom) Entry() *Entry

Entry converts matrix room to search entry

func (*MatrixRoom) Parse

func (r *MatrixRoom) Parse(detector lingua.LanguageDetector, mrsPublicURL string)

Parse matrix room info to prepare custom fields

func (*MatrixRoom) Servers

func (r *MatrixRoom) Servers(ownServerName string) []string

Servers returns all servers from the room object, except own server

type MatrixServer

type MatrixServer struct {
	Name      string               `json:"name"`
	URL       string               `json:"url"`
	Online    bool                 `json:"online"`
	Indexable bool                 `json:"indexable"`
	Contacts  MatrixServerContacts `json:"contacts"` // Contacts as per MSC1929
	OnlineAt  time.Time            `json:"online_at"`
	UpdatedAt time.Time            `json:"updated_at"` // Deprecated
}

MatrixServer info

type MatrixServerContacts

type MatrixServerContacts struct {
	Emails []string `json:"emails"`
	MXIDs  []string `json:"mxids"`
	URL    string   `json:"url"`
}

MatrixServerContacts - MSC1929

func (MatrixServerContacts) IsEmpty

func (c MatrixServerContacts) IsEmpty() bool

type RoomDirectoryFilter

type RoomDirectoryFilter struct {
	GenericSearchTerm string   `json:"generic_search_term"`
	RoomTypes         []string `json:"room_types,omitempty"`
}

RoomDirectoryFilter for the RoomDirectoryRequest

type RoomDirectoryRequest

type RoomDirectoryRequest struct {
	Filter RoomDirectoryFilter `json:"filter"`
	Limit  int                 `json:"limit" query:"limit"`
	Since  string              `json:"since" query:"since"`
}

RoomDirectoryRequest sent when calling POST /_matrix/federation/v1/publicRooms

type RoomDirectoryResponse

type RoomDirectoryResponse struct {
	Chunk     []*RoomDirectoryRoom `json:"chunk"`
	NextBatch string               `json:"next_batch"`
	PrevBatch string               `json:"prev_batch"`
	Total     int                  `json:"total_room_count_estimate"`
}

RoomDirectoryResponse of /_matrix/federation/v1/publicRooms

type RoomDirectoryRoom

type RoomDirectoryRoom struct {
	Avatar        string `json:"avatar_url,omitempty"`
	Alias         string `json:"canonical_alias,omitempty"`
	GuestJoinable bool   `json:"guest_can_join"`
	JoinRule      string `json:"join_rule,omitempty"`
	Name          string `json:"name,omitempty"`
	Members       int    `json:"num_joined_members"`
	ID            string `json:"room_id"`
	RoomType      string `json:"room_type,omitempty"`
	Topic         string `json:"topic,omitempty"`
	WorldReadable bool   `json:"world_readable"`
}

RoomDirectoryRoom is MatrixRoom, but without any computed fields

func (*RoomDirectoryRoom) Convert

func (r *RoomDirectoryRoom) Convert() *MatrixRoom

Convert room directory's room to matrix room

Jump to

Keyboard shortcuts

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