Documentation ¶
Index ¶
- Constants
- Variables
- type Blocklist
- type BlocklistService
- type Cache
- type Config
- type ConfigService
- type Crawler
- func (m *Crawler) AddServer(ctx context.Context, name string) int
- func (m *Crawler) AddServers(ctx context.Context, names []string, workers int)
- func (m *Crawler) DiscoverServers(ctx context.Context, workers int, overrideList ...*utils.List[string, string])
- func (m *Crawler) EachRoom(ctx context.Context, handler func(roomID string, data *model.MatrixRoom) bool)
- func (m *Crawler) GetServersRoomsCount(ctx context.Context) map[string]int
- func (m *Crawler) IndexableServers(ctx context.Context) []string
- func (m *Crawler) OnlineServers(ctx context.Context) []string
- func (m *Crawler) ParseRooms(ctx context.Context, workers int)
- type DataFacade
- func (df *DataFacade) AddServer(ctx context.Context, name string) int
- func (df *DataFacade) AddServers(ctx context.Context, names []string, workers int)
- func (df *DataFacade) DiscoverServers(ctx context.Context, workers int)
- func (df *DataFacade) Full(ctx context.Context, discoveryWorkers, parsingWorkers int)
- func (df *DataFacade) GetServersRoomsCount(ctx context.Context) map[string]int
- func (df *DataFacade) Ingest(ctx context.Context)
- func (df *DataFacade) ParseRooms(ctx context.Context, workers int)
- type DataRepository
- type Email
- type EmailService
- type FederationService
- type Index
- type IndexRepository
- type Lenable
- type Moderation
- func (m *Moderation) Ban(ctx context.Context, roomID string) error
- func (m *Moderation) List(ctx context.Context, serverName ...string) ([]string, error)
- func (m *Moderation) Report(ctx context.Context, roomID, reason string) error
- func (m *Moderation) Unban(ctx context.Context, roomID string) error
- type Plausible
- type Robots
- type RobotsService
- type Search
- type SearchRepository
- type Stats
- func (s *Stats) Collect(ctx context.Context)
- func (s *Stats) CollectServers(ctx context.Context, reload bool)
- func (s *Stats) Get() *model.IndexStats
- func (s *Stats) GetTL(ctx context.Context) map[time.Time]*model.IndexStats
- func (s *Stats) SetFinishedAt(ctx context.Context, process string, finishedAt time.Time)
- func (s *Stats) SetStartedAt(ctx context.Context, process string, startedAt time.Time)
- type StatsRepository
- type StatsService
- type Validator
- type ValidatorService
Constants ¶
const ( // RobotsTxtPublicRooms is matrix federation public rooms endpoint RobotsTxtPublicRooms = "/_matrix/federation/v1/publicRooms" // RobotsTxtPublicRoom is made up endpoint of a specific matrix room, as there is no better option RobotsTxtPublicRoom = "/_matrix/federation/v1/publicRooms/%s" )
const (
// MaxCacheAge to be used on immutable resources
MaxCacheAge = "31536000"
)
Variables ¶
var SearchFieldsBoost = map[string]float64{
"language": 100,
"name": 10,
"server": 10,
"alias": 5,
}
SearchFieldsBoost field name => boost
Functions ¶
This section is empty.
Types ¶
type Blocklist ¶
type Blocklist struct {
// contains filtered or unexported fields
}
Blocklist service
func NewBlocklist ¶
func NewBlocklist(cfg ConfigService) *Blocklist
NewBlocklist creates new blocklist service
type BlocklistService ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache service
func (*Cache) Middleware ¶
func (cache *Cache) Middleware() echo.MiddlewareFunc
Middleware returns cache middleware
func (*Cache) MiddlewareImmutable ¶
func (cache *Cache) MiddlewareImmutable() echo.MiddlewareFunc
MiddlewareImmutable returns echo middleware with immutable in cache-control
func (*Cache) MiddlewareSearch ¶
func (cache *Cache) MiddlewareSearch() echo.MiddlewareFunc
MiddlewareSearch returns cache middleware for search endpoints
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config service
type ConfigService ¶
type Crawler ¶
type Crawler struct {
// contains filtered or unexported fields
}
func NewCrawler ¶
func NewCrawler(cfg ConfigService, fedSvc FederationService, v ValidatorService, block BlocklistService, data DataRepository, detector lingua.LanguageDetector) *Crawler
NewCrawler service
func (*Crawler) AddServer ¶
AddServer by name, intended for HTTP API returns http status code to send to the reporter
func (*Crawler) AddServers ¶
AddServers by name in bulk, intended for HTTP API
func (*Crawler) DiscoverServers ¶
func (m *Crawler) DiscoverServers(ctx context.Context, workers int, overrideList ...*utils.List[string, string])
DiscoverServers across federation and remove invalid ones
func (*Crawler) EachRoom ¶
func (m *Crawler) EachRoom(ctx context.Context, handler func(roomID string, data *model.MatrixRoom) bool)
EachRoom allows to work with each known room
func (*Crawler) GetServersRoomsCount ¶
func (*Crawler) IndexableServers ¶
IndexableServers returns all known indexable servers
func (*Crawler) OnlineServers ¶
OnlineServers returns all known online servers
type DataFacade ¶
type DataFacade struct {
// contains filtered or unexported fields
}
DataFacade wraps all data-related services to provide reusable API across all components of the system
func NewDataFacade ¶
func NewDataFacade( crawler dataCrawlerService, index dataIndexService, stats dataStatsService, cache dataCacheService, ) *DataFacade
NewDataFacade creates new data facade service
func (*DataFacade) AddServer ¶
func (df *DataFacade) AddServer(ctx context.Context, name string) int
AddServer by name, intended for HTTP API returns http status code to send to the reporter
func (*DataFacade) AddServers ¶
func (df *DataFacade) AddServers(ctx context.Context, names []string, workers int)
AddServers by name in bulk, intended for HTTP API
func (*DataFacade) DiscoverServers ¶
func (df *DataFacade) DiscoverServers(ctx context.Context, workers int)
DiscoverServers matrix servers
func (*DataFacade) Full ¶
func (df *DataFacade) Full(ctx context.Context, discoveryWorkers, parsingWorkers int)
Full data pipeline (discovery, parsing, indexing)
func (*DataFacade) GetServersRoomsCount ¶
func (df *DataFacade) GetServersRoomsCount(ctx context.Context) map[string]int
func (*DataFacade) Ingest ¶
func (df *DataFacade) Ingest(ctx context.Context)
Ingest data into search index
func (*DataFacade) ParseRooms ¶
func (df *DataFacade) ParseRooms(ctx context.Context, workers int)
ParseRooms from discovered servers
type DataRepository ¶
type DataRepository interface { AddServer(context.Context, *model.MatrixServer) error HasServer(context.Context, string) bool GetServerInfo(context.Context, string) (*model.MatrixServer, error) FilterServers(context.Context, func(server *model.MatrixServer) bool) map[string]*model.MatrixServer BatchServers(context.Context, []string) error MarkServersOffline(context.Context, []string) RemoveServer(context.Context, string) error RemoveServers(context.Context, []string) AddRoomBatch(context.Context, *model.MatrixRoom) FlushRoomBatch(context.Context) GetRoom(context.Context, string) (*model.MatrixRoom, error) EachRoom(context.Context, func(string, *model.MatrixRoom) bool) SetBiggestRooms(context.Context, []string) error SetServersRoomsCount(ctx context.Context, data map[string]int) error SaveServersRooms(ctx context.Context, data map[string][]string) error GetServersRoomsCount(ctx context.Context) map[string]int GetBannedRooms(context.Context, ...string) ([]string, error) RemoveRooms(context.Context, []string) BanRoom(context.Context, string) error UnbanRoom(context.Context, string) error GetReportedRooms(context.Context, ...string) (map[string]string, error) ReportRoom(context.Context, string, string) error UnreportRoom(context.Context, string) error IsReported(context.Context, string) bool }
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email service
func (*Email) SendModReport ¶
SendModReport sends report email to MRS instance's moderators
func (*Email) SendReport ¶
func (e *Email) SendReport(ctx context.Context, room *model.MatrixRoom, server *model.MatrixServer, reason string, emails []string) error
SendReport sends report email
type EmailService ¶
type FederationService ¶
type FederationService interface { QueryPublicRooms(ctx context.Context, serverName, limit, since string) (*model.RoomDirectoryResponse, error) QueryServerName(ctx context.Context, serverName string) (string, error) QueryVersion(ctx context.Context, serverName string) (string, string, error) QueryCSURL(ctx context.Context, serverName string) string }
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func NewIndex ¶
func NewIndex(cfg ConfigService, index IndexRepository) *Index
NewIndex creates new index service
func (*Index) EmptyIndex ¶
EmptyIndex creates new empty index
func (*Index) IndexBatch ¶
IndexBatch performs indexing of the current batch
type IndexRepository ¶
type Moderation ¶
type Moderation struct {
// contains filtered or unexported fields
}
Moderation service
func NewModeration ¶
func NewModeration(cfg ConfigService, data DataRepository, index IndexRepository, mail EmailService) *Moderation
NewModeration service
func (*Moderation) Ban ¶
func (m *Moderation) Ban(ctx context.Context, roomID string) error
Ban a room
func (*Moderation) List ¶
List returns full list of the banned rooms (optionally from specific server)
type Plausible ¶
type Plausible struct {
// contains filtered or unexported fields
}
Plausible - plausible analytics service
func NewPlausible ¶
func NewPlausible(cfg ConfigService) *Plausible
type Robots ¶
type Robots struct {
// contains filtered or unexported fields
}
Robots - robots.txt parsing Deprecated: This service is deprecated and will be removed in future versions
type RobotsService ¶
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search service
func NewSearch ¶
func NewSearch(cfg ConfigService, data searchDataRepository, repo SearchRepository, block BlocklistService, stats StatsService) *Search
NewSearch creates new search service
type SearchRepository ¶
type SearchRepository interface {
Search(ctx context.Context, searchQuery query.Query, limit, offset int, sortBy []string) ([]*model.Entry, int, error)
}
SearchRepository interface
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats service
func NewStats ¶
func NewStats(cfg ConfigService, data StatsRepository, index, blocklist Lenable) *Stats
NewStats service
func (*Stats) CollectServers ¶
CollectServers stats only
func (*Stats) SetFinishedAt ¶
SetFinishedAt of the process
type StatsRepository ¶
type StatsRepository interface { DataRepository GetIndexStatsTL(ctx context.Context, prefix string) (map[time.Time]*model.IndexStats, error) SetIndexStatsTL(ctx context.Context, calculatedAt time.Time, stats *model.IndexStats) error GetIndexStats(ctx context.Context) *model.IndexStats SetIndexOnlineServers(ctx context.Context, servers int) error SetIndexIndexableServers(ctx context.Context, servers int) error SetIndexBlockedServers(ctx context.Context, servers int) error SetIndexParsedRooms(ctx context.Context, rooms int) error SetIndexIndexedRooms(ctx context.Context, rooms int) error SetIndexBannedRooms(ctx context.Context, rooms int) error SetIndexReportedRooms(ctx context.Context, rooms int) error SetStartedAt(ctx context.Context, process string, startedAt time.Time) error SetFinishedAt(ctx context.Context, process string, finishedAt time.Time) error }
type StatsService ¶
type StatsService interface {
Get() *model.IndexStats
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is matrix validation service
func NewValidator ¶
func NewValidator(cfg ConfigService, block BlocklistService, matrix FederationService, robots RobotsService) *Validator
NewValidator creates new validation service
func (*Validator) IsIndexable ¶
IsIndexable check if server is indexable
func (*Validator) IsRoomAllowed ¶
IsRoomAllowed checks if room is allowed