domain

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package domain contains the domain-level Factory, along with the realtime client/server for SSE connections.

The domain.Factory creates, caches, and produces all of the services that are used by an individual domain.

Index

Constants

View Source
const CollectionAttachment = "Attachment"

CollectionAttachment is the name of the database collection where Attachments are stored

View Source
const CollectionDomain = "Domain"

CollectionGroup is the name of the database collection where the singleton Domain record is stored

View Source
const CollectionEncryptionKey = "EncryptionKey"

CollectionEncryptionKey is the name of the database collection where EncryptionKey records are stored

View Source
const CollectionFolder = "Folder"

CollectionFolder is the name of the database collection where Folder records are stored

View Source
const CollectionFollower = "Follower"

CollectionFollower is the name of the database collection where Follower records are stored

View Source
const CollectionFollowing = "Following"

CollectionFollowing is the name of the database collection where Following records are stored

View Source
const CollectionGroup = "Group"

CollectionGroup is the name of the database collection where Group records are stored

View Source
const CollectionInbox = "Inbox"

CollectionInbox is the database colleciton where user's Inbox records are stored

View Source
const CollectionJWT = "JWT"

CollectionJWT is the database colleciton where user's JWTKey records are stored

View Source
const CollectionMention = "Mention"

CollectionMention is the name of the database collection where Mention records are stored

View Source
const CollectionOAuthClient = "OAuthClient"

CollectionOAuthClient is the name of the database collection where OAuthClients are stored

View Source
const CollectionOAuthUserToken = "OAuthUserToken"

CollectionOAuthUserToken is the name of the database collection where OAuthUserTokens are stored

View Source
const CollectionOutbox = "Outbox"

CollectionOutbox is the name of the database collection where users' Outbox records are stored

View Source
const CollectionResponse = "Response"

CollectionResponse is the name of the database collection where Responses are stored

View Source
const CollectionRule = "Rule"

CollectionRule is the name of the database collection where Rule records are stored

View Source
const CollectionStream = "Stream"

CollectionStream is the name of the database collection where Streams are stored

View Source
const CollectionStreamDraft = "StreamDraft"

CollectionStreamDraft is the name of the database collection where draft changes to streams are stored

View Source
const CollectionStreamResponse = "StreamResponse"

CollectionStreamResponse is the name of the database collection where users' StreamResponse records are stored

View Source
const CollectionTemplate = "Template"

CollectionTemplate is the name of the database collection where Templates are stored

View Source
const CollectionUser = "User"

CollectionUser is the name of the database collection where Users are stored

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	Session data.Session

	MarkForDeletion bool
	// contains filtered or unexported fields
}

Factory knows how to create an populate all services

func NewFactory

func NewFactory(domain config.Domain, providers []config.Provider, activityService *service.ActivityStream, serverEmail *service.ServerEmail, themeService *service.Theme, templateService *service.Template, widgetService *service.Widget, contentService *service.Content, providerService *service.Provider, taskQueue queue.Queue, attachmentOriginals afero.Fs, attachmentCache afero.Fs) (*Factory, error)

NewFactory creates a new factory tied to a MongoDB database

func (*Factory) ActivityStream

func (factory *Factory) ActivityStream() *service.ActivityStream

func (*Factory) Attachment

func (factory *Factory) Attachment() *service.Attachment

Attachment returns a fully populated Attachment service

func (*Factory) AttachmentCache

func (factory *Factory) AttachmentCache() afero.Fs

AttachmentCache returns a reference to the Filesystem where cached/manipulated attachment files are stored.

func (*Factory) AttachmentOriginals

func (factory *Factory) AttachmentOriginals() afero.Fs

AttachmentOriginals returns a reference to the Filesystem where original attachment files are stored

func (*Factory) Close

func (factory *Factory) Close()

Close disconnects any background processes before this factory is destroyed

func (*Factory) Config

func (factory *Factory) Config() config.Domain

func (*Factory) Content

func (factory *Factory) Content() *service.Content

Content returns the Content transformation service

func (*Factory) Domain

func (factory *Factory) Domain() *service.Domain

Domain returns a fully populated Domain service

func (*Factory) Email

func (factory *Factory) Email() *service.DomainEmail

func (*Factory) EncryptionKey

func (factory *Factory) EncryptionKey() *service.EncryptionKey

EncryptionKey returns a fully populated EncryptionKey service

func (*Factory) Folder

func (factory *Factory) Folder() *service.Folder

Folder returns a fully populated Folder service

func (*Factory) Follower

func (factory *Factory) Follower() *service.Follower

Follower returns a fully populated Follower service

func (*Factory) Following

func (factory *Factory) Following() *service.Following

Following returns a fully populated Following service

func (*Factory) Group

func (factory *Factory) Group() *service.Group

Group returns a fully populated Group service

func (*Factory) Host

func (factory *Factory) Host() string

Host returns the domain name AND protocol (probably HTTPS) => "https://example.com")

func (*Factory) Hostname

func (factory *Factory) Hostname() string

Hostname returns the domain name (without anything else) that this factory is responsible for

func (*Factory) ID

func (factory *Factory) ID() string

ID implements the set.Set interface. (Domains are indexed by their hostname)

func (*Factory) Icons

func (factory *Factory) Icons() icon.Provider

Icons returns the icon manager service, which manages aliases for icons in the UI

func (*Factory) Inbox

func (factory *Factory) Inbox() *service.Inbox

Inbox returns a fully populated Inbox service

func (*Factory) JWT

func (factory *Factory) JWT() *service.JWT

Key returns an instance of the Key Manager Service (KMS)

func (*Factory) Locator

func (factory *Factory) Locator() service.Locator

func (*Factory) LookupProvider

func (factory *Factory) LookupProvider(userID primitive.ObjectID) form.LookupProvider

LookupProvider returns a fully populated LookupProvider service

func (*Factory) MediaServer

func (factory *Factory) MediaServer() mediaserver.MediaServer

MediaServer manages all file uploads

func (*Factory) Mention

func (factory *Factory) Mention() *service.Mention

Mention returns a fully populated Mention service

func (*Factory) Model

func (factory *Factory) Model(name string) (service.ModelService, error)

func (*Factory) ModelService added in v0.6.0

func (factory *Factory) ModelService(object data.Object) service.ModelService

ModelService returns the correct service to use for this particular Model object

func (*Factory) OAuthClient added in v0.6.0

func (factory *Factory) OAuthClient() *service.OAuthClient

OAuthClient returns a fully populated OAuthClient service

func (*Factory) OAuthUserToken added in v0.6.0

func (factory *Factory) OAuthUserToken() *service.OAuthUserToken

OAuthUserToken returns a fully populated OAuthUserToken service

func (*Factory) Outbox added in v0.6.0

func (factory *Factory) Outbox() *service.Outbox

Outbox returns a fully populated Outbox service

func (*Factory) Provider

func (factory *Factory) Provider() *service.Provider

OAuth returns a fully populated OAuth service

func (*Factory) Providers

func (factory *Factory) Providers() set.Slice[config.Provider]

func (*Factory) Queue

func (factory *Factory) Queue() queue.Queue

Queue returns the Queue service, which manages background jobs

func (*Factory) RSS

func (factory *Factory) RSS() *service.RSS

RSS returns a fully populated RSS service

func (*Factory) RealtimeBroker

func (factory *Factory) RealtimeBroker() *RealtimeBroker

RealtimeBroker returns a new RealtimeBroker that can push stream updates to connected clients.

func (*Factory) Refresh

func (factory *Factory) Refresh(domain config.Domain, providers []config.Provider, attachmentOriginals afero.Fs, attachmentCache afero.Fs) error

func (*Factory) Response added in v0.6.0

func (factory *Factory) Response() *service.Response

Response returns a fully populated Response service

func (*Factory) Rule added in v0.6.0

func (factory *Factory) Rule() *service.Rule

Rule returns a fully populated Rule service

func (*Factory) Steranko

func (factory *Factory) Steranko() *steranko.Steranko

Steranko returns a fully populated Steranko adapter for the User service.

func (*Factory) Stream

func (factory *Factory) Stream() *service.Stream

Stream returns a fully populated Stream service

func (*Factory) StreamDraft

func (factory *Factory) StreamDraft() *service.StreamDraft

StreamDraft returns a fully populated StreamDraft service

func (*Factory) StreamUpdateChannel

func (factory *Factory) StreamUpdateChannel() chan model.Stream

StreamUpdateChannel initializes a background watcher and returns a channel containing any streams that have changed.

func (*Factory) Template

func (factory *Factory) Template() *service.Template

Template returns a fully populated Template service (managed globally by the server.Factory)

func (*Factory) Theme

func (factory *Factory) Theme() *service.Theme

Theme service manages global website themes (managed globally by the server.Factory)

func (*Factory) User

func (factory *Factory) User() *service.User

User returns a fully populated User service

func (*Factory) Widget

func (factory *Factory) Widget() *service.Widget

Widget returns a fully populated Widget service

type HTTPRequest

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

HTTPRequest wraps an HTTP request and tracks the properties of it that have been accessed. This is used to construct an accurate "Vary" header for cached responses.

func NewHTTPRequest

func NewHTTPRequest(ctx echo.Context) *HTTPRequest

NewHTTPRequest wraps an http.Request object

func (*HTTPRequest) Authorization

func (r *HTTPRequest) Authorization() *model.Authorization

func (*HTTPRequest) Context

func (r *HTTPRequest) Context() context.Context

Context returns the golang context for this http request

func (*HTTPRequest) Partial

func (r *HTTPRequest) Partial() bool

Partial returns TRUE if this is a request for a partial page (HTML fragment), and not a complete HTML page.

func (HTTPRequest) QueryParam

func (r HTTPRequest) QueryParam(name string) string

QueryParam returns a query parameter from the requested URL

func (*HTTPRequest) URL

func (r *HTTPRequest) URL() string

func (*HTTPRequest) UserID

func (r *HTTPRequest) UserID() primitive.ObjectID

UserID returns the userID of the current user

type RealtimeBroker

type RealtimeBroker struct {

	// Channel into which new clients can be pushed
	AddClient chan *RealtimeClient

	// Channel into which disconnected clients should be pushed
	RemoveClient chan *RealtimeClient
	// contains filtered or unexported fields
}

RealtimeBroker is a singleton. It is responsible for keeping a list of which clients (browsers) are currently attached and broadcasting events (messages) to those clients.

TODO: MEDIUM: Should the realtime broker be a service? Is there a reason to have multiple instances of the realtime broker, or should it be a GLOBAL service?

func NewRealtimeBroker

func NewRealtimeBroker(factory *Factory, updates chan model.Stream) RealtimeBroker

NewRealtimeBroker generates a new stream broker

func (*RealtimeBroker) Close

func (b *RealtimeBroker) Close()

Stop closes the broker

func (*RealtimeBroker) Refresh

func (b *RealtimeBroker) Refresh(followerService *service.Follower, queue queue.Queue)

Refresh

type RealtimeClient

type RealtimeClient struct {
	ClientID     primitive.ObjectID      // Unique Identifier of this RealtimeClient.
	HTTPRequest  *HTTPRequest            // HTTP Request that initiated the client
	StreamID     primitive.ObjectID      // Stream.Token of current stream being watched.
	WriteChannel chan primitive.ObjectID // Channel for writing responses to this client.
}

RealtimeClient represents a single SSE connection that has subscribed to updates for a particular stream/view combination.

func NewRealtimeClient

func NewRealtimeClient(httpRequest *HTTPRequest, streamID primitive.ObjectID) *RealtimeClient

NewRealtimeClient initializes a new realtime client.

Jump to

Keyboard shortcuts

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