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
- type Factory
- func (factory *Factory) ActivityStream() *service.ActivityStream
- func (factory *Factory) Attachment() *service.Attachment
- func (factory *Factory) AttachmentCache() afero.Fs
- func (factory *Factory) AttachmentOriginals() afero.Fs
- func (factory *Factory) Close()
- func (factory *Factory) Config() config.Domain
- func (factory *Factory) Content() *service.Content
- func (factory *Factory) Domain() *service.Domain
- func (factory *Factory) Email() *service.DomainEmail
- func (factory *Factory) EncryptionKey() *service.EncryptionKey
- func (factory *Factory) Folder() *service.Folder
- func (factory *Factory) Follower() *service.Follower
- func (factory *Factory) Following() *service.Following
- func (factory *Factory) Group() *service.Group
- func (factory *Factory) Host() string
- func (factory *Factory) Hostname() string
- func (factory *Factory) ID() string
- func (factory *Factory) Icons() icon.Provider
- func (factory *Factory) Inbox() *service.Inbox
- func (factory *Factory) JWT() *service.JWT
- func (factory *Factory) Locator() service.Locator
- func (factory *Factory) LookupProvider(userID primitive.ObjectID) form.LookupProvider
- func (factory *Factory) MediaServer() mediaserver.MediaServer
- func (factory *Factory) Mention() *service.Mention
- func (factory *Factory) Model(name string) (service.ModelService, error)
- func (factory *Factory) ModelService(object data.Object) service.ModelService
- func (factory *Factory) OAuthClient() *service.OAuthClient
- func (factory *Factory) OAuthUserToken() *service.OAuthUserToken
- func (factory *Factory) Outbox() *service.Outbox
- func (factory *Factory) Provider() *service.Provider
- func (factory *Factory) Providers() set.Slice[config.Provider]
- func (factory *Factory) Queue() queue.Queue
- func (factory *Factory) RSS() *service.RSS
- func (factory *Factory) RealtimeBroker() *RealtimeBroker
- func (factory *Factory) Refresh(domain config.Domain, providers []config.Provider, ...) error
- func (factory *Factory) Response() *service.Response
- func (factory *Factory) Rule() *service.Rule
- func (factory *Factory) Steranko() *steranko.Steranko
- func (factory *Factory) Stream() *service.Stream
- func (factory *Factory) StreamDraft() *service.StreamDraft
- func (factory *Factory) StreamUpdateChannel() chan model.Stream
- func (factory *Factory) Template() *service.Template
- func (factory *Factory) Theme() *service.Theme
- func (factory *Factory) User() *service.User
- func (factory *Factory) Widget() *service.Widget
- type HTTPRequest
- type RealtimeBroker
- type RealtimeClient
Constants ¶
const CollectionAttachment = "Attachment"
CollectionAttachment is the name of the database collection where Attachments are stored
const CollectionDomain = "Domain"
CollectionGroup is the name of the database collection where the singleton Domain record is stored
const CollectionEncryptionKey = "EncryptionKey"
CollectionEncryptionKey is the name of the database collection where EncryptionKey records are stored
const CollectionFolder = "Folder"
CollectionFolder is the name of the database collection where Folder records are stored
const CollectionFollower = "Follower"
CollectionFollower is the name of the database collection where Follower records are stored
const CollectionFollowing = "Following"
CollectionFollowing is the name of the database collection where Following records are stored
const CollectionGroup = "Group"
CollectionGroup is the name of the database collection where Group records are stored
const CollectionInbox = "Inbox"
CollectionInbox is the database colleciton where user's Inbox records are stored
const CollectionJWT = "JWT"
CollectionJWT is the database colleciton where user's JWTKey records are stored
const CollectionMention = "Mention"
CollectionMention is the name of the database collection where Mention records are stored
const CollectionOAuthClient = "OAuthClient"
CollectionOAuthClient is the name of the database collection where OAuthClients are stored
const CollectionOAuthUserToken = "OAuthUserToken"
CollectionOAuthUserToken is the name of the database collection where OAuthUserTokens are stored
const CollectionOutbox = "Outbox"
CollectionOutbox is the name of the database collection where users' Outbox records are stored
const CollectionResponse = "Response"
CollectionResponse is the name of the database collection where Responses are stored
const CollectionRule = "Rule"
CollectionRule is the name of the database collection where Rule records are stored
const CollectionStream = "Stream"
CollectionStream is the name of the database collection where Streams are stored
const CollectionStreamDraft = "StreamDraft"
CollectionStreamDraft is the name of the database collection where draft changes to streams are stored
const CollectionStreamResponse = "StreamResponse"
CollectionStreamResponse is the name of the database collection where users' StreamResponse records are stored
const CollectionTemplate = "Template"
CollectionTemplate is the name of the database collection where Templates are stored
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 ¶
AttachmentCache returns a reference to the Filesystem where cached/manipulated attachment files are stored.
func (*Factory) AttachmentOriginals ¶
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) 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) Host ¶
Host returns the domain name AND protocol (probably HTTPS) => "https://example.com")
func (*Factory) Hostname ¶
Hostname returns the domain name (without anything else) that this factory is responsible for
func (*Factory) Icons ¶
Icons returns the icon manager service, which manages aliases for icons in the UI
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) 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) RealtimeBroker ¶
func (factory *Factory) RealtimeBroker() *RealtimeBroker
RealtimeBroker returns a new RealtimeBroker that can push stream updates to connected clients.
func (*Factory) Steranko ¶
Steranko returns a fully populated Steranko adapter for the User service.
func (*Factory) StreamDraft ¶
func (factory *Factory) StreamDraft() *service.StreamDraft
StreamDraft returns a fully populated StreamDraft service
func (*Factory) StreamUpdateChannel ¶
StreamUpdateChannel initializes a background watcher and returns a channel containing any streams that have changed.
func (*Factory) Template ¶
Template returns a fully populated Template service (managed globally by the server.Factory)
func (*Factory) Theme ¶
Theme service manages global website themes (managed globally by the server.Factory)
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
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.