services

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package services represents used services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMatrixClient

func NewMatrixClient(homeserver, username, password string) (MatrixClient, MatrixSyncer, error)

NewMatrixClient - creates matrix client-server API client

Types

type FormExtensions added in v1.1.0

type FormExtensions map[string]formext.Extension

FormExtensions map

type FormHandler

type FormHandler interface {
	HandleGET(string, *http.Request) (string, error)
	HandlePOST(string, *http.Request) (string, error)
}

FormHandler ...

func NewFormHandler

func NewFormHandler(forms []*configuration.Form, exts FormExtensions, spam configuration.Spam, policy FormPolicy, sender FormSender, log Logger) FormHandler

NewFormHandler creates FormHandler object

type FormPolicy

type FormPolicy interface {
	Sanitize(string) string
}

FormPolicy is escape/sanitization policy for all form fields

type FormSender

type FormSender interface {
	SendWebhook(string, string, string, string, string) error
	SendMessage(id.RoomID, string) error
}

FormSender is object that sends forms

type HTTPServer

type HTTPServer interface {
	Start()
}

HTTPServer ...

func NewHTTPServer

func NewHTTPServer(port string, logger Logger, ipMatcher IPMatcher, formHandler FormHandler) HTTPServer

NewHTTPServer creates new HTTP server

type IPMatcher

type IPMatcher interface {
	Match(*http.Request) string
}

IPMatcher tries to match client IP from request headers and returns it as string

type Logger

type Logger interface {
	GetLog() *log.Logger
	Error(message string, args ...interface{})
	Warn(message string, args ...interface{})
	Info(message string, args ...interface{})
	Debug(message string, args ...interface{})
	Trace(message string, args ...interface{})
}

Logger interface

type MatrixBot

type MatrixBot interface {
	SendEncryptedMessage(roomID id.RoomID, message string) error
	SendMessage(roomID id.RoomID, message string) error
	SendWebhook(avatar, name, format, text, url string) error
	Start(displayName string)
	Stop()
}

MatrixBot ...

func NewMatrixBot

func NewMatrixBot(client MatrixClient, syncer MatrixSyncer, machine MatrixOlmMachine, store MatrixStore, cryptoStore MatrixCryptoStore, logger MatrixLogger, registration MatrixRegistrationClient) MatrixBot

NewMatrixBot ...

func NewMatrixBotWithoutStorage

func NewMatrixBotWithoutStorage(client MatrixClient, syncer MatrixSyncer, logger MatrixLogger, registration MatrixRegistrationClient) MatrixBot

NewMatrixBotWithoutStorage without persistent storage

type MatrixClient

type MatrixClient interface {
	SendMessageEvent(id.RoomID, event.Type, interface{}, ...mautrix.ReqSendEvent) (*mautrix.RespSendEvent, error)
	GetOwnDisplayName() (*mautrix.RespUserDisplayName, error)
	SetDisplayName(string) error
	SetPresence(event.Presence) error
	JoinRoomByID(id.RoomID) (*mautrix.RespJoinRoom, error)
	LeaveRoom(id.RoomID) (*mautrix.RespLeaveRoom, error)
	Whoami() (*mautrix.RespWhoami, error)
	Sync() error
	Logout() (*mautrix.RespLogout, error)
}

MatrixClient - matrix client-server API client interface

type MatrixCryptoStore

type MatrixCryptoStore interface {
	crypto.Store
}

MatrixCryptoStore - MatrixOlmMachine store

func NewMatrixCryptoStore

func NewMatrixCryptoStore(db *sql.DB, driver string, logger MatrixLogger, userID id.UserID, deviceID id.DeviceID) (MatrixCryptoStore, error)

NewMatrixCryptoStore returns crypto.Store implementation

type MatrixLogger

type MatrixLogger interface {
	crypto.Logger
	Logger
}

MatrixLogger - matrix logger

type MatrixOlmMachine

type MatrixOlmMachine interface {
	EncryptMegolmEvent(id.RoomID, event.Type, interface{}) (*event.EncryptedEventContent, error)
	DecryptMegolmEvent(*event.Event) (*event.Event, error)
	ProcessSyncResponse(*mautrix.RespSync, string) bool
	ShareGroupSession(id.RoomID, []id.UserID) error
	HandleMemberEvent(*event.Event)
	FlushStore() error
}

MatrixOlmMachine - matrix olm machine

func NewOlmMachine

func NewOlmMachine(client MatrixClient, logger MatrixLogger, cryptoStore MatrixCryptoStore, stateStore MatrixStore) (MatrixOlmMachine, error)

NewOlmMachine returns OLM machine

type MatrixRegistrationClient

type MatrixRegistrationClient interface {
	CreateToken(string, string) (*models.RegistrationToken, error)
	DisableToken(string) (*models.RegistrationToken, error)
	GetList() ([]models.RegistrationToken, error)
	GetRoomID() id.RoomID
	GetStatus(string) (*models.RegistrationToken, error)
}

MatrixRegistrationClient - matrix-registration API client

func NewMatrixRegistrationClient

func NewMatrixRegistrationClient(url string, secret string, roomID id.RoomID) MatrixRegistrationClient

NewMatrixRegistrationClient returns matrix-registration API client

type MatrixStore

type MatrixStore interface {
	mautrix.Storer
	crypto.StateStore
	SetMembership(*event.Event)
	SetEncryptionEvent(*event.Event)
	GetRoomMembers(id.RoomID) []id.UserID
}

MatrixStore - matrix client store & Olm Machine state store

func NewMatrixStore

func NewMatrixStore(db *sql.DB, driver string, logger MatrixLogger) (MatrixStore, error)

NewMatrixStore returns implementation of mautrix.Storer

type MatrixSyncer

type MatrixSyncer interface {
	mautrix.ExtensibleSyncer
}

MatrixSyncer is a wrapper around mautrix default syncer

Jump to

Keyboard shortcuts

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