service

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: 95 Imported by: 0

Documentation

Overview

Package service includes all of the services used in Emissary. This maps loosely to the "Use Cases" concept in the "Clean Architecture" design pattern (https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)

Services include server-level singletons that are used by every domain (such as themes, templates, etc) and domain-level services that have unique instances for each domain.

* Server-level serivces are created by the server.Factory and are passed by reference to each domain factory.

* Domain-level services are created by the domain.Factory, and typically require a connection to a database table, which is why they are not global.

Index

Constants

View Source
const DefinitionEmail = "EMAIL"

DefinitionEmail marks a filesystem that contains an Email definition.

View Source
const DefinitionTemplate = "TEMPLATE"

DefinitionEmail marks a filesystem that contains a stream Template definition.

View Source
const DefinitionTheme = "THEME"

DefinitionEmail marks a filesystem that contains a domain Theme definition.

View Source
const DefinitionWidget = "WIDGET"

DefinitionWidget marks a filesystem that contains a Widget definition.

Variables

This section is empty.

Functions

func ParseProfileURL

func ParseProfileURL(value string) (urlValue *url.URL, userID primitive.ObjectID, objectType string, objectID primitive.ObjectID, err error)

func ParseProfileURL_AsFollowing

func ParseProfileURL_AsFollowing(value string) (primitive.ObjectID, primitive.ObjectID, error)

func ParseProfileURL_UserID

func ParseProfileURL_UserID(value string) (primitive.ObjectID, error)

func WatchStreams

func WatchStreams(collection *mongo.Collection, result chan<- model.Stream)

WatchStreams initiates a mongodb change stream to on every updates to Stream data objects

Types

type ActivityStream

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

ActivityStream implements the Hannibal HTTP client interface, and provides a cache for ActivityStream documents.

func NewActivityStream

func NewActivityStream() ActivityStream

NewActivityStream creates a new ActivityStream service

func (*ActivityStream) Delete

func (service *ActivityStream) Delete(url string) error

Delete removes a single document from the database by its URL

func (*ActivityStream) Load

func (service *ActivityStream) Load(url string, options ...any) (streams.Document, error)

Load implements the Hannibal `Client` interface, and returns a streams.Document from the cache.

func (*ActivityStream) NewDocument added in v0.6.0

func (service *ActivityStream) NewDocument(document map[string]any) streams.Document

func (*ActivityStream) PurgeCache added in v0.6.0

func (service *ActivityStream) PurgeCache() error

PurgeCache removes all expired documents from the cache

func (*ActivityStream) Put added in v0.6.0

func (service *ActivityStream) Put(document streams.Document)

Put adds a single document to the ActivityStream cache

func (*ActivityStream) QueryAnnouncesBeforeDate added in v0.6.0

func (service *ActivityStream) QueryAnnouncesBeforeDate(relationHref string, maxDate int64, done <-chan struct{}) <-chan streams.Document

func (*ActivityStream) QueryLikesBeforeDate added in v0.6.0

func (service *ActivityStream) QueryLikesBeforeDate(relationHref string, maxDate int64, done <-chan struct{}) <-chan streams.Document

func (*ActivityStream) QueryRepliesAfterDate added in v0.6.0

func (service *ActivityStream) QueryRepliesAfterDate(inReplyTo string, minDate int64, done <-chan struct{}) <-chan streams.Document

QueryRepliesAfterDate returns a slice of streams.Document values that are replies to the specified document, and were published after the specified date.

func (*ActivityStream) QueryRepliesBeforeDate added in v0.6.0

func (service *ActivityStream) QueryRepliesBeforeDate(inReplyTo string, maxDate int64, done <-chan struct{}) <-chan streams.Document

QueryRepliesBeforeDate returns a slice of streams.Document values that are replies to the specified document, and were published before the specified date.

func (*ActivityStream) Refresh

func (service *ActivityStream) Refresh(innerClient streams.Client, cacheClient *ascache.Client, collection data.Collection)

Refresh updates the ActivityStream service with new dependencies

func (*ActivityStream) SearchActors added in v0.6.0

func (service *ActivityStream) SearchActors(queryString string) ([]model.ActorSummary, error)

type Attachment

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

Attachment manages all interactions with the Attachment collection

func NewAttachment

func NewAttachment() Attachment

NewAttachment returns a fully populated Attachment service

func (*Attachment) Close

func (service *Attachment) Close()

Close stops any background processes controlled by this service

func (*Attachment) Delete

func (service *Attachment) Delete(attachment *model.Attachment, note string) error

Delete removes an Attachment from the database (virtual delete)

func (*Attachment) DeleteAll

func (service *Attachment) DeleteAll(objectType string, objectID primitive.ObjectID, note string) error

DeleteByStream removes all attachments from the provided stream (virtual delete)

func (*Attachment) DeleteByID

func (service *Attachment) DeleteByID(objectType string, objectID primitive.ObjectID, attachmentID primitive.ObjectID, note string) error

func (*Attachment) List

func (service *Attachment) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Attachments who match the provided criteria

func (*Attachment) Load

func (service *Attachment) Load(criteria exp.Expression, result *model.Attachment) error

Load retrieves an Attachment from the database

func (*Attachment) LoadByID

func (service *Attachment) LoadByID(objectType string, objectID primitive.ObjectID, attachmentID primitive.ObjectID, result *model.Attachment) error

func (*Attachment) LoadFirstByObjectID

func (service *Attachment) LoadFirstByObjectID(objectType string, objectID primitive.ObjectID) (model.Attachment, error)

func (*Attachment) New

func (service *Attachment) New() model.Attachment

New creates a newly initialized Attachment that is ready to use

func (*Attachment) Query

func (service *Attachment) Query(criteria exp.Expression, options ...option.Option) ([]model.Attachment, error)

func (*Attachment) QueryByObjectID

func (service *Attachment) QueryByObjectID(objectType string, objectID primitive.ObjectID) ([]model.Attachment, error)

func (*Attachment) Refresh

func (service *Attachment) Refresh(collection data.Collection, mediaServer mediaserver.MediaServer, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Attachment) Save

func (service *Attachment) Save(attachment *model.Attachment, note string) error

Save adds/updates an Attachment in the database

func (*Attachment) Schema

func (service *Attachment) Schema() schema.Schema

type AuthorSetter added in v0.6.0

type AuthorSetter interface {
	SetAuthor(object data.Object, authorID primitive.ObjectID) error
}

type Config

type Config struct {
}

Config service (will) manage server-wide configuration

type Content

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

func NewContent

func NewContent(editorJS *goeditorjs.HTMLEngine) Content
func (service *Content) ApplyLinks(content *model.Content)

func (*Content) ApplyTags added in v0.6.0

func (service *Content) ApplyTags(content *model.Content, tags []model.Tag)

func (*Content) Format added in v0.6.0

func (service *Content) Format(content *model.Content)

func (*Content) FormatByExtension added in v0.6.0

func (service *Content) FormatByExtension(extension string) string

func (*Content) New

func (service *Content) New(format string, raw string) model.Content

func (*Content) NewByExtension added in v0.6.0

func (service *Content) NewByExtension(extension string, raw string) model.Content

type Domain

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

Domain service manages all access to the singleton model.Domain in the database

func NewDomain

func NewDomain() Domain

NewDomain returns a fully initialized Domain service

func (*Domain) ActiveClients

func (service *Domain) ActiveClients() []model.Client

ActiveClients returns all active Clients for this domain

func (*Domain) Client

func (service *Domain) Client(providerID string) model.Client

func (*Domain) Close

func (service *Domain) Close()

Close stops the following service watcher

func (*Domain) Get

func (service *Domain) Get() model.Domain

Load retrieves an Domain from the database (or in-memory cache)

func (*Domain) GetOAuthToken

func (service *Domain) GetOAuthToken(providerID string) (model.Client, *oauth2.Token, error)

GetAuthToken retrieves the OAuth token for the specified provider. If the token has expired then it is refreshed (and saved) automatically before returning.

func (*Domain) GetPointer added in v0.6.0

func (service *Domain) GetPointer() *model.Domain

func (*Domain) HasSignupForm added in v0.6.0

func (service *Domain) HasSignupForm() bool

HasSignupForm returns TRUE if this domain allows new users to sign up.

func (*Domain) LoadDomain added in v0.6.0

func (service *Domain) LoadDomain() (model.Domain, error)

func (*Domain) LoadOrCreateDomain

func (service *Domain) LoadOrCreateDomain() (model.Domain, error)

LoadOrCreate domain guarantees that a domain record exists in the database. It returns A COPY of the service domain.

func (*Domain) ManualProvider

func (service *Domain) ManualProvider(providerID string) (providers.ManualProvider, bool)

ManualProvider returns the external.ManualProvider that matches the given providerID

func (*Domain) NewOAuthClient

func (service *Domain) NewOAuthClient(providerID string) (model.Client, error)

NewOAuthState generates and returns a new OAuth state for the specified provider

func (*Domain) OAuthClientCallbackURL added in v0.6.0

func (service *Domain) OAuthClientCallbackURL(providerID string) string

OAuthClientCallbackURL returns the specific callback URL to use for this host and provider.

func (*Domain) OAuthCodeURL

func (service *Domain) OAuthCodeURL(providerID string) (string, error)

OAuthCodeURL generates a new (unique) OAuth state and AuthCodeURL for the specified provider

func (*Domain) OAuthExchange

func (service *Domain) OAuthExchange(providerID string, state string, code string) error

OAuthExchange trades a temporary OAuth code for a valid OAuth token

func (*Domain) OAuthProvider

func (service *Domain) OAuthProvider(providerID string) (providers.OAuthProvider, bool)

OAuthProvider returns the external.OAuthProvider that matches the given providerID

func (*Domain) ObjectDelete

func (service *Domain) ObjectDelete(object data.Object, note string) error

func (*Domain) ObjectID

func (service *Domain) ObjectID(object data.Object) primitive.ObjectID

func (*Domain) ObjectList

func (service *Domain) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Domain) ObjectLoad

func (service *Domain) ObjectLoad(_ exp.Expression) (data.Object, error)

func (*Domain) ObjectNew

func (service *Domain) ObjectNew() data.Object

New returns a fully initialized model.Stream as a data.Object.

func (*Domain) ObjectQuery

func (service *Domain) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Domain) ObjectSave

func (service *Domain) ObjectSave(object data.Object, note string) error

func (*Domain) ObjectType

func (service *Domain) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Domain) ObjectUserCan

func (service *Domain) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Domain) Provider

func (service *Domain) Provider(providerID string) (providers.Provider, bool)

Provider returns the external Provider that matches the given providerID

func (*Domain) ReadOAuthClient

func (service *Domain) ReadOAuthClient(providerID string) (model.Client, bool)

ReadOAuthState returns the OAuth state for the specified provider WITHOUT changing the current value. THIS SHOULD NOT BE USED TO ACCESS OAUTH TOKENS because they may be expired. Use GetOAuthToken for that.

func (*Domain) Ready

func (service *Domain) Ready() bool

Ready returns TRUE if the service is ready to use

func (*Domain) Refresh

func (service *Domain) Refresh(collection data.Collection, configuration config.Domain, themeService *Theme, userService *User, providerService *Provider, funcMap template.FuncMap)

Refresh updates any stateful data that is cached inside this service.

func (*Domain) Save

func (service *Domain) Save(domain model.Domain, note string) error

Save updates the value of this domain in the database (and in-memory cache)

func (*Domain) Schema

func (service *Domain) Schema() schema.Schema

func (*Domain) Theme

func (service *Domain) Theme() model.Theme

type DomainEmail

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

func NewDomainEmail

func NewDomainEmail(serverEmail *ServerEmail) DomainEmail

func (*DomainEmail) Refresh

func (service *DomainEmail) Refresh(configuration config.Domain)

func (*DomainEmail) SendPasswordReset

func (service *DomainEmail) SendPasswordReset(user *model.User) error

SendPasswordReset sends a passowrd reset email to the user. This method swallows errors so that it can be run asynchronously.

func (*DomainEmail) SendWelcome

func (service *DomainEmail) SendWelcome(user *model.User) error

SendWelcome sends a welcome email to the user. This method returns an error so that it CAN NOT be run asynchronously.

type EncryptionKey

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

EncryptionKey defines a service that tracks the (possibly external) accounts an internal User is encryptionKey.

func NewEncryptionKey

func NewEncryptionKey() EncryptionKey

NewEncryptionKey returns a fully initialized EncryptionKey service

func (*EncryptionKey) Close

func (service *EncryptionKey) Close()

Close stops any background processes controlled by this service

func (*EncryptionKey) Create

func (service *EncryptionKey) Create(parentType string, parentID primitive.ObjectID) (model.EncryptionKey, error)

func (*EncryptionKey) Delete

func (service *EncryptionKey) Delete(encryptionKey *model.EncryptionKey, note string) error

Delete removes an EncryptionKey from the database (virtual delete)

func (*EncryptionKey) GetPrivateKey

func (service *EncryptionKey) GetPrivateKey(encryptionKey *model.EncryptionKey) (*rsa.PrivateKey, error)

func (*EncryptionKey) GetPublicKey

func (service *EncryptionKey) GetPublicKey(encryptionKey *model.EncryptionKey) (*rsa.PublicKey, error)

func (*EncryptionKey) KeyID

func (service *EncryptionKey) KeyID(encryptionKey *model.EncryptionKey) string

KeyID returns the publicly accessible URL of this EncryptionKey

func (*EncryptionKey) List

func (service *EncryptionKey) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the EncryptionKeys who match the provided criteria

func (*EncryptionKey) Load

func (service *EncryptionKey) Load(criteria exp.Expression, encryptionKey *model.EncryptionKey) error

Load retrieves an EncryptionKey from the database

func (*EncryptionKey) LoadByParentID added in v0.6.0

func (service *EncryptionKey) LoadByParentID(parentType string, parentID primitive.ObjectID, encryptionKey *model.EncryptionKey) error

LoadByID tries to load the EncryptionKey from the database. If no key exists for the designated user, then a new one is generated.

func (*EncryptionKey) OwnerID

func (service *EncryptionKey) OwnerID(encryptionKey *model.EncryptionKey) string

OwnerID returns the publicly accessible URL of the Actor who owns this EncryptionKey

func (*EncryptionKey) Refresh

func (service *EncryptionKey) Refresh(collection data.Collection, host string)

Refresh updates any stateful data that is cached inside this service.

func (*EncryptionKey) Save

func (service *EncryptionKey) Save(encryptionKey *model.EncryptionKey, note string) error

Save adds/updates an EncryptionKey in the database

func (*EncryptionKey) Sign

func (service *EncryptionKey) Sign(message []byte, encryptionKey *model.EncryptionKey) ([]byte, error)

func (*EncryptionKey) Verify

func (service *EncryptionKey) Verify(message []byte, signature []byte, encryptionKey *model.EncryptionKey) error

type Filesystem

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

Filesystem is a service that multiplexes between different filesystems. Currently works with embedded filesystems and file:// URIs

func NewFilesystem

func NewFilesystem(embedded fs.FS) Filesystem

NewFilesytem returns a fully initialized Filesystem service

func (*Filesystem) GetAfero

func (filesystem *Filesystem) GetAfero(folder mapof.String) (afero.Fs, error)

GetAfero returns READ/WRITE a filesystem. It works with file:// URIs

func (*Filesystem) GetAferos

func (filesystem *Filesystem) GetAferos(folders ...mapof.String) []afero.Fs

GetAferos returns multiple afero filesystems

func (*Filesystem) GetFS

func (filesystem *Filesystem) GetFS(folder mapof.String) (fs.FS, error)

GetFS returns a READONLY Filesystem. It works with embed:// and file:// URIs

func (*Filesystem) GetFSs

func (filesystem *Filesystem) GetFSs(folders ...mapof.String) []fs.FS

GetFSs returns multiple fs.FS filesystems

func (*Filesystem) Watch

func (filesystem *Filesystem) Watch(folder mapof.String, changes chan<- bool, done <-chan channel.Done) error

Watch listens to changes to this filesystem with implementation-specific adapters. Currently only supports file:// URIs

type Folder

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

Folder manages all interactions with a user's Folder

func NewFolder

func NewFolder() Folder

NewFolder returns a fully populated Folder service

func (*Folder) CalculateUnreadCount added in v0.6.0

func (service *Folder) CalculateUnreadCount(userID primitive.ObjectID, folderID primitive.ObjectID) error

CalculateUnreadCount counts the number of items in a folder that were created AFTER the provided minRank, then updates the folder's "unreadCount" and "readDate" fields

func (*Folder) Close

func (service *Folder) Close()

Close stops any background processes controlled by this service

func (*Folder) CreateDefaultFolders

func (service *Folder) CreateDefaultFolders(userID primitive.ObjectID) error

func (*Folder) Delete

func (service *Folder) Delete(folder *model.Folder, note string) error

Delete removes an Folder from the database (virtual delete)

func (*Folder) List

func (service *Folder) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Folders that match the provided criteria

func (*Folder) ListByUserID

func (service *Folder) ListByUserID(userID primitive.ObjectID) (data.Iterator, error)

ListByUserID returns an iterator containing all of the Folders for a given user

func (*Folder) Load

func (service *Folder) Load(criteria exp.Expression, result *model.Folder) error

Load retrieves an Folder from the database

func (*Folder) LoadByID

func (service *Folder) LoadByID(userID primitive.ObjectID, folderID primitive.ObjectID, result *model.Folder) error

LoadByID loads a single stream that matches the provided ID

func (*Folder) LoadByLabel

func (service *Folder) LoadByLabel(userID primitive.ObjectID, label string, result *model.Folder) error

LoadByLabel loads a single stream that matches the provided label

func (*Folder) LoadByOriginURL

func (service *Folder) LoadByOriginURL(userID primitive.ObjectID, originURL string, result *model.Folder) error

LoadBySource locates a single stream that matches the provided OriginURL

func (*Folder) LoadByToken

func (service *Folder) LoadByToken(userID primitive.ObjectID, token string, result *model.Folder) error

LoadByToken loads a single stream that matches the provided token

func (*Folder) New

func (service *Folder) New() model.Folder

New creates a newly initialized Folder that is ready to use

func (*Folder) ObjectDelete

func (service *Folder) ObjectDelete(object data.Object, comment string) error

func (*Folder) ObjectID

func (service *Folder) ObjectID(object data.Object) primitive.ObjectID

func (*Folder) ObjectList

func (service *Folder) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Folder) ObjectLoad

func (service *Folder) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Folder) ObjectNew

func (service *Folder) ObjectNew() data.Object

New returns a fully initialized model.Group as a data.Object.

func (*Folder) ObjectQuery

func (service *Folder) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Folder) ObjectSave

func (service *Folder) ObjectSave(object data.Object, comment string) error

func (*Folder) ObjectType

func (service *Folder) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Folder) ObjectUserCan

func (service *Folder) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Folder) Query

func (service *Folder) Query(criteria exp.Expression, options ...option.Option) ([]model.Folder, error)

Query returns a slice of Folders that math the provided criteria

func (*Folder) QueryByUserID

func (service *Folder) QueryByUserID(userID primitive.ObjectID) ([]model.Folder, error)

QueryByUserID returns all folders for a given user

func (*Folder) ReCalculateUnreadCountFromFolder added in v0.6.0

func (service *Folder) ReCalculateUnreadCountFromFolder(userID primitive.ObjectID, folderID primitive.ObjectID) error

func (*Folder) Refresh

func (service *Folder) Refresh(collection data.Collection, themeService *Theme, domainService *Domain, inboxService *Inbox)

Refresh updates any stateful data that is cached inside this service.

func (*Folder) Save

func (service *Folder) Save(folder *model.Folder, note string) error

Save adds/updates an Folder in the database

func (*Folder) Schema

func (service *Folder) Schema() schema.Schema

func (*Folder) SetUnreadCount added in v0.6.0

func (service *Folder) SetUnreadCount(userID primitive.ObjectID, folderID primitive.ObjectID, unreadCount int) error

SetUnreadCount uses an optimized query to update the the "readDate" and "unreadCount" of a particular folder

type FolderLookupProvider

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

func NewFolderLookupProvider

func NewFolderLookupProvider(folderService *Folder, userID primitive.ObjectID) FolderLookupProvider

func (FolderLookupProvider) Add

func (service FolderLookupProvider) Add(name string) (string, error)

func (FolderLookupProvider) Get

func (service FolderLookupProvider) Get() []form.LookupCode

func (FolderLookupProvider) Group

func (service FolderLookupProvider) Group(name string) form.LookupGroup

type Follower

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

func NewFollower

func NewFollower() Follower

NewFollower returns a fully initialized Follower service

func (*Follower) ActivityPubFollowersChannel added in v0.6.0

func (service *Follower) ActivityPubFollowersChannel(parentType string, parentID primitive.ObjectID) (<-chan model.Follower, error)

ActivityPubFollowersChannel returns a channel containing all of the Followers of specific parentID who use ActivityPub for updates

func (*Follower) ActivityPubID

func (service *Follower) ActivityPubID(follower *model.Follower) string

func (*Follower) ActivityPubObjectID

func (service *Follower) ActivityPubObjectID(follower *model.Follower) string

func (*Follower) AsJSONLD

func (service *Follower) AsJSONLD(follower *model.Follower) mapof.Any

func (*Follower) Channel added in v0.6.0

func (service *Follower) Channel(criteria exp.Expression, options ...option.Option) (<-chan model.Follower, error)

Channel returns a channel containing all of the Followers who match the provided criteria

func (*Follower) Close

func (service *Follower) Close()

Close stops any background processes controlled by this service

func (*Follower) Delete

func (service *Follower) Delete(follower *model.Follower, note string) error

Delete removes an Follower from the database (virtual delete)

func (*Follower) FollowersChannel added in v0.6.0

func (service *Follower) FollowersChannel(parentType string, parentID primitive.ObjectID) (<-chan model.Follower, error)

FollowersChannel returns a channel containing all of the Followers of specific parentID

func (*Follower) IsActivityPubFollower added in v0.6.0

func (service *Follower) IsActivityPubFollower(streamID primitive.ObjectID, followerURL string) bool

IsActivityPubFollower searches

func (*Follower) List

func (service *Follower) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Followers who match the provided criteria

func (*Follower) ListActivityPub

func (service *Follower) ListActivityPub(parentID primitive.ObjectID, options ...option.Option) (data.Iterator, error)

ListActivityPub returns an iterator containing all of the Followers of specific parentID

func (*Follower) ListByParent added in v0.6.0

func (service *Follower) ListByParent(parentID primitive.ObjectID, options ...option.Option) (data.Iterator, error)

ListByParent returns an iterator containing all of the Followers of specific parentID

func (*Follower) Load

func (service *Follower) Load(criteria exp.Expression, follower *model.Follower) error

Load retrieves an Follower from the database

func (*Follower) LoadByActivityPubFollower

func (service *Follower) LoadByActivityPubFollower(parentID primitive.ObjectID, followerURL string, follower *model.Follower) error

func (*Follower) LoadByActor

func (service *Follower) LoadByActor(parentID primitive.ObjectID, actorID string, follower *model.Follower) error

LoadByActor retrieves an Follower from the database by parentID and actorID

func (*Follower) LoadByToken

func (service *Follower) LoadByToken(parentID primitive.ObjectID, token string, follower *model.Follower) error

LoadByToken loads a follower using either the FollowerID (if an ObjectID is passed) or the Actor's ProfileURL

func (*Follower) LoadByWebSub

func (service *Follower) LoadByWebSub(objectType string, parentID primitive.ObjectID, callback string, result *model.Follower) error

LoadByWebSub retrieves a follower based on the parentID and callback

func (*Follower) LoadOrCreate

func (service *Follower) LoadOrCreate(parentID primitive.ObjectID, actorID string) (model.Follower, error)

func (*Follower) LoadOrCreateByWebSub added in v0.6.0

func (service *Follower) LoadOrCreateByWebSub(objectType string, parentID primitive.ObjectID, callback string) (model.Follower, error)

LoadOrCreateByWebSub finds a follower based on the parentID and callback. If no follower is found, a new record is created.

func (*Follower) NewActivityPubFollower

func (service *Follower) NewActivityPubFollower(parentType string, parentID primitive.ObjectID, actor streams.Document, follower *model.Follower) error

func (*Follower) ObjectDelete

func (service *Follower) ObjectDelete(object data.Object, comment string) error

func (*Follower) ObjectID

func (service *Follower) ObjectID(object data.Object) primitive.ObjectID

func (*Follower) ObjectList

func (service *Follower) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Follower) ObjectLoad

func (service *Follower) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Follower) ObjectNew

func (service *Follower) ObjectNew() data.Object

New returns a fully initialized model.Group as a data.Object.

func (*Follower) ObjectQuery

func (service *Follower) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Follower) ObjectSave

func (service *Follower) ObjectSave(object data.Object, comment string) error

func (*Follower) ObjectType

func (service *Follower) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Follower) ObjectUserCan

func (service *Follower) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Follower) Query

func (service *Follower) Query(criteria exp.Expression, options ...option.Option) ([]model.Follower, error)

func (*Follower) QueryByParentAndDate added in v0.6.0

func (service *Follower) QueryByParentAndDate(parentType string, parentID primitive.ObjectID, method string, maxCreateDate int64, pageSize int) ([]model.Follower, error)

func (*Follower) Refresh

func (service *Follower) Refresh(collection data.Collection, userService *User, ruleService *Rule, activityService *ActivityStream, queue queue.Queue, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Follower) RemoteActor added in v0.6.0

func (service *Follower) RemoteActor(follower *model.Follower) (streams.Document, error)

RemoteActor returns the ActivityStream document for a remote Actor for a specific Follower

func (*Follower) Save

func (service *Follower) Save(follower *model.Follower, note string) error

Save adds/updates an Follower in the database

func (*Follower) Schema

func (service *Follower) Schema() schema.Schema

func (*Follower) WebSubFollowersChannel added in v0.6.0

func (service *Follower) WebSubFollowersChannel(parentType string, parentID primitive.ObjectID) (<-chan model.Follower, error)

WebSubFollowersChannel returns a channel containing all of the Followers of specific parentID who use WebSub for updates

type Following

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

Following manages all interactions with the Following collection

func NewFollowing

func NewFollowing() Following

NewFollowing returns a fully populated Following service.

func (*Following) ActivityPubActorID

func (service *Following) ActivityPubActorID(following *model.Following) string

ActivityPubActorID returns the public URL (ID) of the actor being followed

func (*Following) ActivityPubID

func (service *Following) ActivityPubID(following *model.Following) string

ActivityPubID returns the public URL (ID) of a Following record

func (*Following) AsJSONLD

func (service *Following) AsJSONLD(following *model.Following) mapof.Any

AsJSONLD returns a Following record as a JSON-LD object

func (*Following) Close

func (service *Following) Close()

Close stops the following service watcher

func (*Following) Connect

func (service *Following) Connect(following model.Following) error

Connect attempts to connect to a new URL and determines how to follow it.

func (*Following) Delete

func (service *Following) Delete(following *model.Following, note string) error

Delete removes an Following from the database (virtual delete)

func (*Following) Disconnect

func (service *Following) Disconnect(following *model.Following)

func (*Following) GetFollowingID added in v0.6.0

func (service *Following) GetFollowingID(userID primitive.ObjectID, uri string) (string, error)

func (*Following) List

func (service *Following) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Following who match the provided criteria

func (*Following) ListActivityPub

func (service *Following) ListActivityPub(userID primitive.ObjectID, options ...option.Option) (data.Iterator, error)

func (*Following) ListByUserID

func (service *Following) ListByUserID(userID primitive.ObjectID) (data.Iterator, error)

ListByUserID returns an iterator of all following for a given userID

func (*Following) ListPollable

func (service *Following) ListPollable() (data.Iterator, error)

ListPollable returns an iterator of all following that are ready to be polled

func (*Following) Load

func (service *Following) Load(criteria exp.Expression, result *model.Following) error

Load retrieves an Following from the database

func (*Following) LoadByID

func (service *Following) LoadByID(userID primitive.ObjectID, followingID primitive.ObjectID, result *model.Following) error

LoadByID retrieves an Following from the database. UserID is required to prevent people from snooping on other's following.

func (*Following) LoadByToken

func (service *Following) LoadByToken(userID primitive.ObjectID, token string, result *model.Following) error

LoadByToken loads an individual following using a string version of the following ID

func (*Following) LoadByURL

func (service *Following) LoadByURL(userID primitive.ObjectID, profileUrl string, result *model.Following) error

LoadByURL loads an individual following using the target URL that is being followed

func (*Following) New

func (service *Following) New() model.Following

New creates a newly initialized Following that is ready to use

func (*Following) ObjectDelete

func (service *Following) ObjectDelete(object data.Object, note string) error

func (*Following) ObjectID

func (service *Following) ObjectID(object data.Object) primitive.ObjectID

ObjectID returns the ID of a following object

func (*Following) ObjectList

func (service *Following) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Following) ObjectLoad

func (service *Following) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Following) ObjectNew

func (service *Following) ObjectNew() data.Object

New returns a fully initialized model.Stream as a data.Object.

func (*Following) ObjectQuery

func (service *Following) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Following) ObjectSave

func (service *Following) ObjectSave(object data.Object, note string) error

func (*Following) ObjectType

func (service *Following) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Following) ObjectUserCan

func (service *Following) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Following) PurgeInbox

func (service *Following) PurgeInbox(following model.Following) error

PurgeInbox removes all inbox items that are past their expiration date. TODO: LOW: Should this be in the Inbox service?

func (*Following) Query

func (service *Following) Query(criteria exp.Expression, options ...option.Option) ([]model.Following, error)

Query returns an iterator containing all of the Following who match the provided criteria

func (*Following) QueryByFolder

func (service *Following) QueryByFolder(userID primitive.ObjectID, folderID primitive.ObjectID) ([]model.FollowingSummary, error)

QueryByFolder returns a slice of all following for a given user

func (*Following) QueryByFolderAndExp added in v0.6.0

func (service *Following) QueryByFolderAndExp(userID primitive.ObjectID, folderID primitive.ObjectID, criteria exp.Expression) ([]model.FollowingSummary, error)

QueryByFolderAndExp returns a slice of all following for a given user

func (*Following) QueryByUser

func (service *Following) QueryByUser(userID primitive.ObjectID) ([]model.FollowingSummary, error)

QueryByUser returns a slice of all following for a given user

func (*Following) Refresh

func (service *Following) Refresh(collection data.Collection, streamService *Stream, userService *User, inboxService *Inbox, folderService *Folder, keyService *EncryptionKey, activityService *ActivityStream, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Following) RefreshAndConnect added in v0.6.0

func (service *Following) RefreshAndConnect(following model.Following)

func (*Following) Save

func (service *Following) Save(following *model.Following, note string) error

Save adds/updates an Following in the database

func (*Following) SaveMessage added in v0.6.0

func (service *Following) SaveMessage(following *model.Following, document streams.Document, originType string) error

saveToInbox adds/updates an individual Message based on an RSS item. It returns TRUE if a new record was created

func (*Following) Schema

func (service *Following) Schema() schema.Schema

func (*Following) SetStatusFailure added in v0.6.0

func (service *Following) SetStatusFailure(following *model.Following, statusMessage string) error

SetStatusFailure updates a Following record to the "Failure" status and increments the error count.

func (*Following) SetStatusLoading added in v0.6.0

func (service *Following) SetStatusLoading(following *model.Following) error

SetStatusLoading updates a Following record with the "Loading" status

func (*Following) SetStatusSuccess added in v0.6.0

func (service *Following) SetStatusSuccess(following *model.Following) error

SetStatusSuccess updates a Following record with the "Success" status and resets the error count to zero.

func (*Following) Start

func (service *Following) Start()

Start begins the background scheduler that checks each following according to its own polling frequency TODO: HIGH: Need to make this configurable on a per-physical-server basis so that clusters can work together without hammering the Following collection.

type Group

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

Group manages all interactions with the Group collection

func NewGroup

func NewGroup() Group

NewGroup returns a fully populated Group service

func (*Group) Close

func (service *Group) Close()

Close stops any background processes controlled by this service

func (*Group) Count

func (service *Group) Count(criteria exp.Expression) (int64, error)

Count returns the number of (non-deleted) records in the User collection

func (*Group) Delete

func (service *Group) Delete(group *model.Group, note string) error

Delete removes an Group from the database (virtual delete)

func (*Group) List

func (service *Group) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Groups who match the provided criteria

func (*Group) ListAsOptions

func (service *Group) ListAsOptions() []form.LookupCode

func (*Group) ListByGroup

func (service *Group) ListByGroup(group string) (data.Iterator, error)

ListByGroup returns all groups that match a provided group name

func (*Group) ListByIDs

func (service *Group) ListByIDs(groupIDs ...primitive.ObjectID) ([]model.Group, error)

func (*Group) Load

func (service *Group) Load(criteria exp.Expression, result *model.Group) error

Load retrieves an Group from the database

func (*Group) LoadByID

func (service *Group) LoadByID(groupID primitive.ObjectID, result *model.Group) error

LoadByID loads a single model.Group object that matches the provided groupID

func (*Group) LoadByToken

func (service *Group) LoadByToken(token string, result *model.Group) error

LoadByGroupname loads a single Group object that matches the provided token

func (*Group) ObjectDelete

func (service *Group) ObjectDelete(object data.Object, comment string) error

func (*Group) ObjectID

func (service *Group) ObjectID(object data.Object) primitive.ObjectID

func (*Group) ObjectList

func (service *Group) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Group) ObjectLoad

func (service *Group) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Group) ObjectNew

func (service *Group) ObjectNew() data.Object

New returns a fully initialized model.Group as a data.Object.

func (*Group) ObjectQuery

func (service *Group) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Group) ObjectSave

func (service *Group) ObjectSave(object data.Object, comment string) error

func (*Group) ObjectType

func (service *Group) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Group) ObjectUserCan

func (service *Group) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Group) Query

func (service *Group) Query(criteria exp.Expression, options ...option.Option) ([]model.Group, error)

func (*Group) Refresh

func (service *Group) Refresh(collection data.Collection)

Refresh updates any stateful data that is cached inside this service.

func (*Group) Save

func (service *Group) Save(group *model.Group, note string) error

Save adds/updates an Group in the database

func (*Group) Schema

func (service *Group) Schema() schema.Schema

func (*Group) Startup added in v0.6.0

func (service *Group) Startup(theme *model.Theme) error

type GroupLookupProvider

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

func NewGroupLookupProvider

func NewGroupLookupProvider(groupService *Group) GroupLookupProvider

func (GroupLookupProvider) Add

func (service GroupLookupProvider) Add(name string) (string, error)

func (GroupLookupProvider) Get

func (service GroupLookupProvider) Get() []form.LookupCode

type Icons

type Icons struct{}

func (Icons) Get

func (service Icons) Get(name string) string

func (Icons) Write

func (service Icons) Write(name string, writer io.Writer)

type Inbox

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

Inbox manages all Inbox records for a User. This includes Inbox and Outbox

func NewInbox

func NewInbox() Inbox

NewInbox returns a fully populated Inbox service

func (*Inbox) CalculateRank

func (service *Inbox) CalculateRank(message *model.Message)

CalculateRank generates a unique rank for the message based on the PublishDate and the number of messages that already exist in the database with this PublishDate.

func (*Inbox) Close

func (service *Inbox) Close()

Close stops any background processes controlled by this service

func (*Inbox) CountUnreadMessages added in v0.6.0

func (service *Inbox) CountUnreadMessages(userID primitive.ObjectID, folderID primitive.ObjectID) (int, error)

CountUnreadMessages counts the number of messages for a user/folder that are marked "unread".

func (*Inbox) Delete

func (service *Inbox) Delete(message *model.Message, note string) error

Delete removes an Inbox from the database (virtual delete)

func (*Inbox) DeleteByFolder

func (service *Inbox) DeleteByFolder(userID primitive.ObjectID, folderID primitive.ObjectID) error

func (*Inbox) DeleteByOrigin

func (service *Inbox) DeleteByOrigin(internalID primitive.ObjectID, note string) error

func (*Inbox) DeleteMany

func (service *Inbox) DeleteMany(criteria exp.Expression, note string) error

DeleteMany removes all child streams from the provided stream (virtual delete)

func (*Inbox) List

func (service *Inbox) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Activities that match the provided criteria

func (*Inbox) ListByFolder

func (service *Inbox) ListByFolder(userID primitive.ObjectID, folderID primitive.ObjectID) (data.Iterator, error)

func (*Inbox) ListByFollowingID

func (service *Inbox) ListByFollowingID(userID primitive.ObjectID, followingID primitive.ObjectID) (data.Iterator, error)

func (*Inbox) Load

func (service *Inbox) Load(criteria exp.Expression, result *model.Message) error

Load retrieves an Inbox from the database

func (*Inbox) LoadByID

func (service *Inbox) LoadByID(userID primitive.ObjectID, messageID primitive.ObjectID, result *model.Message) error

func (*Inbox) LoadByRank

func (service *Inbox) LoadByRank(userID primitive.ObjectID, folderID primitive.ObjectID, rankExpression exp.Expression, result *model.Message, options ...option.Option) error

func (*Inbox) LoadByURL

func (service *Inbox) LoadByURL(userID primitive.ObjectID, url string, result *model.Message) error

LoadByURL returns the first message that matches the provided UserID and URL

func (*Inbox) LoadOldestUnread added in v0.6.0

func (service *Inbox) LoadOldestUnread(userID primitive.ObjectID, message *model.Message) error

func (*Inbox) LoadSibling added in v0.6.0

func (service *Inbox) LoadSibling(folderID primitive.ObjectID, rank int64, following string, direction string) (model.Message, error)

LoadSibling searches for the previous/next sibling to the provided message criteria.

func (*Inbox) LoadUnreadByURL added in v0.6.0

func (service *Inbox) LoadUnreadByURL(userID primitive.ObjectID, url string, result *model.Message) error

LoadUnreadByURL returns the first UNREAD message that matches the provided UserID and URL

func (*Inbox) MarkMuted added in v0.6.0

func (service *Inbox) MarkMuted(message *model.Message) error

func (*Inbox) MarkRead added in v0.6.0

func (service *Inbox) MarkRead(message *model.Message) error

MarkRead updates a message to "READ" status and recalculates statistics

func (*Inbox) MarkReadByDate added in v0.6.0

func (service *Inbox) MarkReadByDate(userID primitive.ObjectID, rank int64) error

func (*Inbox) MarkUnmuted added in v0.6.0

func (service *Inbox) MarkUnmuted(message *model.Message) error

func (*Inbox) MarkUnread added in v0.6.0

func (service *Inbox) MarkUnread(message *model.Message) error

MarkRead updates a message to "UNREAD" status and recalculates statistics

func (*Inbox) New

func (service *Inbox) New() model.Message

New creates a newly initialized Inbox that is ready to use

func (*Inbox) ObjectDelete

func (service *Inbox) ObjectDelete(object data.Object, note string) error

func (*Inbox) ObjectID

func (service *Inbox) ObjectID(object data.Object) primitive.ObjectID

func (*Inbox) ObjectList

func (service *Inbox) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Inbox) ObjectLoad

func (service *Inbox) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Inbox) ObjectNew

func (service *Inbox) ObjectNew() data.Object

New returns a fully initialized model.Stream as a data.Object.

func (*Inbox) ObjectQuery

func (service *Inbox) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Inbox) ObjectSave

func (service *Inbox) ObjectSave(object data.Object, note string) error

func (*Inbox) ObjectType

func (service *Inbox) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Inbox) ObjectUserCan

func (service *Inbox) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Inbox) Query

func (service *Inbox) Query(criteria exp.Expression, options ...option.Option) ([]model.Message, error)

Query returns a slice containing all of the Activities that match the provided criteria

func (*Inbox) QueryByUserID

func (service *Inbox) QueryByUserID(userID primitive.ObjectID, criteria exp.Expression, options ...option.Option) ([]model.Message, error)

func (*Inbox) QueryPurgeable

func (service *Inbox) QueryPurgeable(following *model.Following) ([]model.Message, error)

QueryPurgeable returns a list of Inboxs that are older than the purge date for this following TODO: HIGH: ReadDate is gone. Need another way to purge messages.

func (*Inbox) Refresh

func (service *Inbox) Refresh(collection data.Collection, ruleService *Rule, folderService *Folder, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Inbox) Save

func (service *Inbox) Save(message *model.Message, note string) error

Save adds/updates an Inbox in the database

func (*Inbox) Schema

func (service *Inbox) Schema() schema.Schema

func (*Inbox) UpdateInboxFolders

func (service *Inbox) UpdateInboxFolders(userID primitive.ObjectID, followingID primitive.ObjectID, folderID primitive.ObjectID)

type JWT

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

JWT is a service that generates and validates JWT keys.

func NewJWT added in v0.6.0

func NewJWT() JWT

func (*JWT) Close added in v0.6.0

func (service *JWT) Close()

func (*JWT) FindJWTKey

func (service *JWT) FindJWTKey(token *jwt.Token) (any, error)

FindJWTKey retrieves a key from the cache or database, and returns it to the caller. This method is a part of the steranko.KeyService interface.

func (*JWT) NewJWTKey

func (service *JWT) NewJWTKey() (string, any)

NewJWTKey returns a a new JWT Key to the caller. This method is a part of the steranko.KeyService interface.

func (*JWT) Parse added in v0.6.0

func (service *JWT) Parse(request *http.Request) (*jwt.Token, error)

Parse retrieves a JWT token from the request, and parses it into a JWT token. This method is a part of the steranko.KeyService interface.

func (*JWT) ParseString added in v0.6.0

func (service *JWT) ParseString(tokenString string) (*jwt.Token, error)

func (*JWT) Refresh added in v0.6.0

func (service *JWT) Refresh(collection data.Collection, keyEncryptingKey []byte)

type Locator

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

func NewLocator

func NewLocator(userService *User, streamService *Stream, host string) Locator

func (Locator) GetObjectFromURL

func (service Locator) GetObjectFromURL(value string) (string, primitive.ObjectID, error)

GetObjectFromURL parses a URL and verifies the existence of the referenced object.

type LookupProvider

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

func NewLookupProvider

func NewLookupProvider(themeService *Theme, groupService *Group, folderService *Folder, userID primitive.ObjectID) LookupProvider

func (LookupProvider) Group

func (service LookupProvider) Group(path string) form.LookupGroup

type Mention

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

Mention defines a service that can send and receive mention data

func NewMention

func NewMention() Mention

NewMention returns a fully initialized Mention service

func (*Mention) Close

func (service *Mention) Close()

Close stops any background processes controlled by this service

func (*Mention) Delete

func (service *Mention) Delete(mention *model.Mention, note string) error

Delete removes an Mention from the database (virtual delete)

func (*Mention) DiscoverEndpoint

func (service *Mention) DiscoverEndpoint(url string) (string, error)

DiscoverEndpoint tries to find the Mention endpoint for the provided URL

func (service *Mention) FindLinks(body string) []string

func (*Mention) GetPageInfo added in v0.6.0

func (service *Mention) GetPageInfo(body *bytes.Buffer, originURL string, mention *model.Mention) error

TODO: HIGH: This should use a common service to get URL data from Microformats, OpenGraph, JSON-LD, etc.

func (*Mention) List

func (service *Mention) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Mentions that match the provided criteria

func (*Mention) Load

func (service *Mention) Load(criteria exp.Expression, mention *model.Mention) error

Load retrieves an Mention from the database

func (*Mention) LoadByOrigin added in v0.6.0

func (service *Mention) LoadByOrigin(objectType string, objectID primitive.ObjectID, originURL string, result *model.Mention) error

LoadByOrigin loads an existing Mention by its type/objectID/origin URL

func (*Mention) LoadOrCreate added in v0.6.0

func (service *Mention) LoadOrCreate(objectType string, objectID primitive.ObjectID, originURL string) (model.Mention, error)

LoadOrCreate loads an existing Mention or creates a new one if it doesn't exist

func (*Mention) ObjectDelete

func (service *Mention) ObjectDelete(object data.Object, comment string) error

func (*Mention) ObjectID

func (service *Mention) ObjectID(object data.Object) primitive.ObjectID

func (*Mention) ObjectList

func (service *Mention) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Mention) ObjectLoad

func (service *Mention) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Mention) ObjectNew

func (service *Mention) ObjectNew() data.Object

New returns a fully initialized model.Group as a data.Object.

func (*Mention) ObjectQuery

func (service *Mention) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Mention) ObjectSave

func (service *Mention) ObjectSave(object data.Object, comment string) error

func (*Mention) ObjectType

func (service *Mention) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Mention) ObjectUserCan

func (service *Mention) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Mention) ParseURL added in v0.6.0

func (service *Mention) ParseURL(target string) (objectType string, token string, err error)

TODO: LOW: This should just use the Locator service. ParseURL inspects a target URL and determines what kind of object it is and what the token is.

func (*Mention) Query

func (service *Mention) Query(criteria exp.Expression, options ...option.Option) ([]model.Mention, error)

Query returns a slice containing all of the Mentions that match the provided criteria

func (*Mention) QueryByObjectID

func (service *Mention) QueryByObjectID(objectID primitive.ObjectID, options ...option.Option) ([]model.Mention, error)

func (*Mention) Refresh

func (service *Mention) Refresh(collection data.Collection, ruleService *Rule, activityService *ActivityStream, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Mention) Save

func (service *Mention) Save(mention *model.Mention, note string) error

Save adds/updates an Mention in the database

func (*Mention) Schema

func (service *Mention) Schema() schema.Schema

func (*Mention) Send

func (service *Mention) Send(source string, target string) error

Send will send a mention to the target's endpoint

func (*Mention) Verify

func (service *Mention) Verify(source string, target string, buffer io.Writer) error

Verify confirms that the source document includes a link to the target document

type ModelService

type ModelService interface {
	ObjectType() string
	ObjectID(data.Object) primitive.ObjectID
	ObjectNew() data.Object
	ObjectQuery(any, exp.Expression, ...option.Option) error
	ObjectList(exp.Expression, ...option.Option) (data.Iterator, error)
	ObjectLoad(exp.Expression) (data.Object, error)
	ObjectSave(data.Object, string) error
	ObjectDelete(data.Object, string) error
	ObjectUserCan(data.Object, model.Authorization, string) error
	Schema() schema.Schema
}

ModelService interface wraps the generic Object-* functions that standard services provide

type OAuthClient added in v0.6.0

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

OAuthClient manages all interactions with the OAuthClient collection

func NewOAuthClient added in v0.6.0

func NewOAuthClient() OAuthClient

NewOAuthClient returns a fully populated OAuthClient service.

func (*OAuthClient) Close added in v0.6.0

func (service *OAuthClient) Close()

Close stops any background processes controlled by this service

func (*OAuthClient) Delete added in v0.6.0

func (service *OAuthClient) Delete(app *model.OAuthClient, note string) error

Delete removes an OAuthClient from the database (virtual delete)

func (*OAuthClient) Iterator added in v0.6.0

func (service *OAuthClient) Iterator(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

Iterator returns an iterator containing all of the OAuthClients that match the provided criteria

func (*OAuthClient) Load added in v0.6.0

func (service *OAuthClient) Load(criteria exp.Expression, application *model.OAuthClient) error

Load retrieves an OAuthClient from the database

func (*OAuthClient) LoadByClientID added in v0.6.0

func (service *OAuthClient) LoadByClientID(clientID primitive.ObjectID, client *model.OAuthClient) error

LoadByClientID loads a single application using the "client_id" field (which is just a stringified ObjectID)

func (*OAuthClient) Query added in v0.6.0

func (service *OAuthClient) Query(criteria exp.Expression, options ...option.Option) ([]model.OAuthClient, error)

Query returns an slice containing all of the OAuthClients that match the provided criteria

func (*OAuthClient) Refresh added in v0.6.0

func (service *OAuthClient) Refresh(collection data.Collection, oauthUserTokenService *OAuthUserToken, host string)

Refresh updates any stateful data that is cached inside this service.

func (*OAuthClient) Save added in v0.6.0

func (service *OAuthClient) Save(app *model.OAuthClient, note string) error

Save adds/updates an OAuthClient in the database

func (*OAuthClient) Schema added in v0.6.0

func (service *OAuthClient) Schema() schema.Schema

func (*OAuthClient) ValidateClientSecret added in v0.6.0

func (service *OAuthClient) ValidateClientSecret(clientID primitive.ObjectID, clientSecret string) error

type OAuthUserToken added in v0.6.0

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

OAuthUserToken manages all interactions with the OAuthUserToken collection

func NewOAuthUserToken added in v0.6.0

func NewOAuthUserToken() OAuthUserToken

NewOAuthUserToken returns a fully populated OAuthUserToken service.

func (*OAuthUserToken) Close added in v0.6.0

func (service *OAuthUserToken) Close()

Close stops any background processes controlled by this service

func (*OAuthUserToken) Create added in v0.6.0

func (service *OAuthUserToken) Create(client model.OAuthClient, authorization model.Authorization, transaction model.OAuthAuthorizationRequest) (model.OAuthUserToken, error)

Create creates a new OAuthUserToken for the provided application and authorization

func (*OAuthUserToken) CreateFromUser added in v0.6.0

func (service *OAuthUserToken) CreateFromUser(user *model.User, clientID primitive.ObjectID, scope string) (model.OAuthUserToken, error)

func (*OAuthUserToken) Delete added in v0.6.0

func (service *OAuthUserToken) Delete(application *model.OAuthUserToken, note string) error

Delete removes an OAuthUserToken from the database (virtual delete)

func (*OAuthUserToken) DeleteByClient added in v0.6.0

func (service *OAuthUserToken) DeleteByClient(clientID primitive.ObjectID, note string) error

func (*OAuthUserToken) DeleteMany added in v0.6.0

func (service *OAuthUserToken) DeleteMany(criteria exp.Expression, note string) error

DeleteMany removes all child streams from the provided stream (virtual delete)

func (*OAuthUserToken) Iterator added in v0.6.0

func (service *OAuthUserToken) Iterator(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

Iterator returns an iterator containing all of the OAuthUserTokens that match the provided criteria

func (*OAuthUserToken) JWT added in v0.6.0

func (service *OAuthUserToken) JWT(userID primitive.ObjectID, scopes string) (string, error)

JWT encodes an OAuthUserToken as a new JWT.

func (*OAuthUserToken) Load added in v0.6.0

func (service *OAuthUserToken) Load(criteria exp.Expression, application *model.OAuthUserToken) error

Load retrieves an OAuthUserToken from the database

func (*OAuthUserToken) LoadByClientAndCode added in v0.6.0

func (service *OAuthUserToken) LoadByClientAndCode(userTokenID primitive.ObjectID, clientID primitive.ObjectID, clientSecret string, result *model.OAuthUserToken) error

func (*OAuthUserToken) LoadByClientAndToken added in v0.6.0

func (service *OAuthUserToken) LoadByClientAndToken(clientID primitive.ObjectID, clientSecret string, token string, result *model.OAuthUserToken) error

func (*OAuthUserToken) LoadByUserAndClient added in v0.6.0

func (service *OAuthUserToken) LoadByUserAndClient(userID primitive.ObjectID, clientID primitive.ObjectID, result *model.OAuthUserToken) error

func (*OAuthUserToken) Query added in v0.6.0

func (service *OAuthUserToken) Query(criteria exp.Expression, options ...option.Option) ([]model.OAuthUserToken, error)

Query returns an slice containing all of the OAuthUserTokens that match the provided criteria

func (*OAuthUserToken) Refresh added in v0.6.0

func (service *OAuthUserToken) Refresh(collection data.Collection, oauthClientService *OAuthClient, jwtService *JWT, host string)

Refresh updates any stateful data that is cached inside this service.

func (*OAuthUserToken) Save added in v0.6.0

func (service *OAuthUserToken) Save(application *model.OAuthUserToken, note string) error

Save adds/updates an OAuthUserToken in the database

func (*OAuthUserToken) Schema added in v0.6.0

func (service *OAuthUserToken) Schema() schema.Schema

type Origin

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

Origin service polls external Stream origins for new external Streams.

func NewOrigin

func NewOrigin(domainService *Domain, streamService *Stream, providerService *Provider) Origin

NewOrigin returns a fully initialized Origin service

func (*Origin) Close

func (service *Origin) Close()

func (*Origin) Poll

func (service *Origin) Poll(providerID string) <-chan model.Stream

func (*Origin) PollAll

func (service *Origin) PollAll() <-chan model.Stream

func (*Origin) Refresh

func (service *Origin) Refresh(domainService *Domain, streamService *Stream, providerService *Provider)

func (*Origin) Save

func (service *Origin) Save(streams <-chan model.Stream) error

type Outbox added in v0.6.0

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

Outbox manages all Outbox records for a User. This includes Outbox and Outbox

func NewOutbox added in v0.6.0

func NewOutbox() Outbox

NewOutbox returns a fully populated Outbox service

func (*Outbox) Close added in v0.6.0

func (service *Outbox) Close()

Close stops any background processes controlled by this service

func (*Outbox) Delete added in v0.6.0

func (service *Outbox) Delete(outboxMessage *model.OutboxMessage, note string) error

Delete removes an Outbox from the database (virtual delete)

func (*Outbox) DeleteByURL added in v0.6.0

func (service *Outbox) DeleteByURL(parentType string, parentID primitive.ObjectID, url string) error

func (*Outbox) List added in v0.6.0

func (service *Outbox) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Activities that match the provided criteria

func (*Outbox) Load added in v0.6.0

func (service *Outbox) Load(criteria exp.Expression, result *model.OutboxMessage) error

Load retrieves an Outbox from the database

func (*Outbox) LoadByURL added in v0.6.0

func (service *Outbox) LoadByURL(parentType string, parentID primitive.ObjectID, url string, result *model.OutboxMessage) error

func (*Outbox) LoadOrCreate added in v0.6.0

func (service *Outbox) LoadOrCreate(parentType string, parentID primitive.ObjectID, url string) (model.OutboxMessage, error)

func (*Outbox) New added in v0.6.0

func (service *Outbox) New() model.OutboxMessage

New creates a newly initialized Outbox that is ready to use

func (*Outbox) Publish added in v0.6.0

func (service *Outbox) Publish(actor *outbox.Actor, parentType string, parentID primitive.ObjectID, activity mapof.Any) error

Publish adds an OutboxMessage to the Actor's Outbox and sends notifications to all Followers.

func (*Outbox) Query added in v0.6.0

func (service *Outbox) Query(criteria exp.Expression, options ...option.Option) ([]model.OutboxMessage, error)

Query returns a slice containing all of the Activities that match the provided criteria

func (*Outbox) QueryByParentID added in v0.6.0

func (service *Outbox) QueryByParentID(parentType string, parentID primitive.ObjectID, criteria exp.Expression, options ...option.Option) ([]model.OutboxMessage, error)

func (*Outbox) QueryByUserAndDate added in v0.6.0

func (service *Outbox) QueryByUserAndDate(parentType string, parentID primitive.ObjectID, maxDate int64, maxRows int) ([]model.OutboxMessageSummary, error)

func (*Outbox) Refresh added in v0.6.0

func (service *Outbox) Refresh(collection data.Collection, streamService *Stream, activityService *ActivityStream, followerService *Follower, templateService *Template, userService *User, queue queue.Queue)

Refresh updates any stateful data that is cached inside this service.

func (*Outbox) Save added in v0.6.0

func (service *Outbox) Save(outboxMessage *model.OutboxMessage, note string) error

Save adds/updates an Outbox in the database

func (*Outbox) UnPublish added in v0.6.0

func (service *Outbox) UnPublish(actor *outbox.Actor, parentType string, parentID primitive.ObjectID, url string) error

UnPublish deletes an OutboxMessage from the Outbox, and sends notifications to all Followers

type Provider

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

Provider service manages all access to external services

func NewProvider

func NewProvider(providers []config.Provider) Provider

NewProvider returns a fully initialized Provider service

func (*Provider) GetGiphyProvider

func (service *Provider) GetGiphyProvider() providers.Giphy

func (*Provider) GetProvider

func (service *Provider) GetProvider(providerID string) (providers.Provider, bool)

GetProvider returns a populated adapter for the given provider

func (*Provider) Refresh

func (service *Provider) Refresh(providers []config.Provider)

Refresh updates the list of clients

type RSS

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

RSS service generates RSS feeds of the available streams in the database

func NewRSS

func NewRSS(streamService *Stream, host string) *RSS

NewRSS returns a fully initialized RSS service

func (RSS) Feed

func (rss RSS) Feed(criteria ...exp.Expression) (*feeds.JSONFeed, error)

Feed generates an RSS data feed based on the provided query criteria. This feed has a lot of incomplete data at the top level, so we're expecting the handler that calls this to fill in the rest of the gaps before it passes the values back to the requester.

func (RSS) Item

func (rss RSS) Item(stream model.Stream) *feeds.JSONItem

Item converts a single model.Stream into a feeds.JSONItem

type Response added in v0.6.0

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

Response defines a service that can send and receive response data

func NewResponse added in v0.6.0

func NewResponse() Response

NewResponse returns a fully initialized Response service

func (*Response) Close added in v0.6.0

func (service *Response) Close()

Close stops any background processes controlled by this service

func (*Response) CountByContent added in v0.6.0

func (service *Response) CountByContent(objectID string) (mapof.Int, error)

func (*Response) Delete added in v0.6.0

func (service *Response) Delete(response *model.Response, note string) error

Delete removes an Response from the database (hard delete)

func (*Response) List added in v0.6.0

func (service *Response) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Responses that match the provided criteria

func (*Response) Load added in v0.6.0

func (service *Response) Load(criteria exp.Expression, response *model.Response) error

Load retrieves an Response from the database

func (*Response) LoadByActorAndObject added in v0.6.0

func (service *Response) LoadByActorAndObject(actor string, object string, responseType string, response *model.Response) error

func (*Response) LoadByID added in v0.6.0

func (service *Response) LoadByID(responseID primitive.ObjectID, response *model.Response) error

func (*Response) LoadByUserAndObject added in v0.6.0

func (service *Response) LoadByUserAndObject(userID primitive.ObjectID, object string, responseType string, response *model.Response) error

func (*Response) ObjectDelete added in v0.6.0

func (service *Response) ObjectDelete(object data.Object, note string) error

func (*Response) ObjectID added in v0.6.0

func (service *Response) ObjectID(object data.Object) primitive.ObjectID

func (*Response) ObjectList added in v0.6.0

func (service *Response) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Response) ObjectLoad added in v0.6.0

func (service *Response) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Response) ObjectNew added in v0.6.0

func (service *Response) ObjectNew() data.Object

New returns a fully initialized model.Response as a data.Object.

func (*Response) ObjectQuery added in v0.6.0

func (service *Response) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Response) ObjectSave added in v0.6.0

func (service *Response) ObjectSave(object data.Object, note string) error

func (*Response) ObjectType added in v0.6.0

func (service *Response) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Response) ObjectUserCan added in v0.6.0

func (service *Response) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Response) Query added in v0.6.0

func (service *Response) Query(criteria exp.Expression, options ...option.Option) ([]model.Response, error)

Query returns a slice containing all of the Responses that match the provided criteria

func (*Response) QueryByObjectAndDate added in v0.6.0

func (service *Response) QueryByObjectAndDate(objectID string, responseType string, maxDate int64, pageSize int) ([]model.Response, error)

func (*Response) QueryByUserAndDate added in v0.6.0

func (service *Response) QueryByUserAndDate(userID primitive.ObjectID, responseType string, maxDate int64, pageSize int) ([]model.Response, error)

func (*Response) QueryByUserAndObject added in v0.6.0

func (service *Response) QueryByUserAndObject(userID primitive.ObjectID, object string, options ...option.Option) ([]model.Response, error)

func (*Response) Refresh added in v0.6.0

func (service *Response) Refresh(collection data.Collection, userService *User, outboxService *Outbox, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Response) Save added in v0.6.0

func (service *Response) Save(response *model.Response, note string) error

Save adds/updates an Response in the database

func (*Response) Schema added in v0.6.0

func (service *Response) Schema() schema.Schema

func (*Response) SetResponse added in v0.6.0

func (service *Response) SetResponse(user *model.User, url string, responseType string, content string) error

SetResponse is the preferred way of creating/updating a Response. It includes the business logic to search for an existing response, and delete it if one exists already (publishing UNDO actions in the process).

func (*Response) UnsetResponse added in v0.6.0

func (service *Response) UnsetResponse(user *model.User, url string, responseType string) error

UnsetReponse removes a reponse based on the User, URL, and Response Type

type Rule added in v0.6.0

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

Rule defines a service that manages all content rules created and imported by Users.

func NewRule added in v0.6.0

func NewRule() Rule

NewRule returns a fully initialized Rule service

func (*Rule) ActivityPubActorURL added in v0.6.0

func (service *Rule) ActivityPubActorURL(rule model.Rule) string

func (*Rule) ActivityPubURL added in v0.6.0

func (service *Rule) ActivityPubURL(rule model.Rule) string

func (*Rule) Channel added in v0.6.0

func (service *Rule) Channel(criteria exp.Expression, options ...option.Option) (<-chan model.Rule, error)

Channel returns a channel that will stream all of the Rules that match the provided criteria

func (*Rule) Close added in v0.6.0

func (service *Rule) Close()

Close stops any background processes controlled by this service

func (*Rule) Delete added in v0.6.0

func (service *Rule) Delete(rule *model.Rule, note string) error

Delete removes an Rule from the database (virtual delete)

func (*Rule) Filter added in v0.6.0

func (service *Rule) Filter(userID primitive.ObjectID, options ...RuleFilterOption) RuleFilter

func (*Rule) JSONLD added in v0.6.0

func (service *Rule) JSONLD(rule model.Rule) mapof.Any

JSONLD returns a JSON-LD representation of the provided Rule

func (*Rule) JSONLDGetter added in v0.6.0

func (service *Rule) JSONLDGetter(rule model.Rule) RuleJSONLDGetter

JSONLDGetter returns a new JSONLDGetter for the provided stream

func (*Rule) List added in v0.6.0

func (service *Rule) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Rules that match the provided criteria

func (*Rule) Load added in v0.6.0

func (service *Rule) Load(criteria exp.Expression, rule *model.Rule) error

Load retrieves an Rule from the database

func (*Rule) LoadByFollowing added in v0.6.0

func (service *Rule) LoadByFollowing(userID primitive.ObjectID, followingID primitive.ObjectID, ruleType string, trigger string, rule *model.Rule) error

LoadByFollowing retrieves a single Rule that maches the provided User, Following, RuleType, and Trigger

func (*Rule) LoadByID added in v0.6.0

func (service *Rule) LoadByID(userID primitive.ObjectID, ruleID primitive.ObjectID, rule *model.Rule) error

func (*Rule) LoadByToken added in v0.6.0

func (service *Rule) LoadByToken(userID primitive.ObjectID, token string, rule *model.Rule) error

func (*Rule) LoadByTrigger added in v0.6.0

func (service *Rule) LoadByTrigger(userID primitive.ObjectID, ruleType string, trigger string, rule *model.Rule) error

LoadByTrigger retrieves a single Rule that maches the provided User, RuleType, and Trigger

func (*Rule) ObjectDelete added in v0.6.0

func (service *Rule) ObjectDelete(object data.Object, comment string) error

func (*Rule) ObjectID added in v0.6.0

func (service *Rule) ObjectID(object data.Object) primitive.ObjectID

func (*Rule) ObjectList added in v0.6.0

func (service *Rule) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Rule) ObjectLoad added in v0.6.0

func (service *Rule) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Rule) ObjectNew added in v0.6.0

func (service *Rule) ObjectNew() data.Object

New returns a fully initialized model.Group as a data.Object.

func (*Rule) ObjectQuery added in v0.6.0

func (service *Rule) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Rule) ObjectSave added in v0.6.0

func (service *Rule) ObjectSave(object data.Object, comment string) error

func (*Rule) ObjectType added in v0.6.0

func (service *Rule) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Rule) ObjectUserCan added in v0.6.0

func (service *Rule) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Rule) Query added in v0.6.0

func (service *Rule) Query(criteria exp.Expression, options ...option.Option) ([]model.Rule, error)

Query returns an slice of allthe Rules that match the provided criteria

func (*Rule) QueryBlockedActors added in v0.6.0

func (service *Rule) QueryBlockedActors(userID primitive.ObjectID) ([]model.Rule, error)

QueryBlockedActors returns all Actors blocked by this User (or by the Domain on behalf of the User)

func (*Rule) QueryByActor added in v0.6.0

func (service *Rule) QueryByActor(userID primitive.ObjectID, actorID string) ([]model.RuleSummary, error)

QueryByActor retrieves a slice of RuleSummaries that match the provided User and Actor

func (*Rule) QueryByActorAndActions added in v0.6.0

func (service *Rule) QueryByActorAndActions(userID primitive.ObjectID, actorID string, actions ...string) ([]model.RuleSummary, error)

QueryByActorAndActions retrieves a slice of RuleSummaries that match the provided User, Actor, and potential actions

func (*Rule) QueryByType added in v0.6.0

func (service *Rule) QueryByType(userID primitive.ObjectID, ruleType string, criteria exp.Expression, options ...option.Option) ([]model.Rule, error)

func (*Rule) QueryByTypeActor added in v0.6.0

func (service *Rule) QueryByTypeActor(userID primitive.ObjectID, criteria exp.Expression, options ...option.Option) ([]model.Rule, error)

func (*Rule) QueryByTypeContent added in v0.6.0

func (service *Rule) QueryByTypeContent(userID primitive.ObjectID, criteria exp.Expression, options ...option.Option) ([]model.Rule, error)

func (*Rule) QueryByTypeDomain added in v0.6.0

func (service *Rule) QueryByTypeDomain(userID primitive.ObjectID, criteria exp.Expression, options ...option.Option) ([]model.Rule, error)

func (*Rule) QueryDomainBlocks added in v0.6.0

func (service *Rule) QueryDomainBlocks() ([]model.Rule, error)

QueryDomainBlocks returns all external domains blocked by this Instance/Domain.

func (*Rule) QueryPublic added in v0.6.0

func (service *Rule) QueryPublic(userID primitive.ObjectID, maxDate int64, options ...option.Option) ([]model.Rule, error)

QueryPublic returns a collection of Rules that are marked Public, in reverse chronological order.

func (*Rule) QuerySummary added in v0.6.0

func (service *Rule) QuerySummary(criteria exp.Expression, options ...option.Option) ([]model.RuleSummary, error)

QuerySummary returns an slice of allthe Rules that match the provided criteria

func (*Rule) Refresh added in v0.6.0

func (service *Rule) Refresh(collection data.Collection, outboxService *Outbox, userService *User, queue queue.Queue, host string)

Refresh updates any stateful data that is cached inside this service.

func (*Rule) Save added in v0.6.0

func (service *Rule) Save(rule *model.Rule, note string) error

Save adds/updates an Rule in the database

func (*Rule) Schema added in v0.6.0

func (service *Rule) Schema() schema.Schema

type RuleFilter added in v0.6.0

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

RuleFilter is a temporary object that filters ActivityStream documents based on the User- and Domain-Rules that are active for a given UserID. Each RuleFilter can be used as many times as needed for a single User and HTTP Request. RuleFilters are not thread-safe, and should not be shared between goroutines.

func NewRuleFilter added in v0.6.0

func NewRuleFilter(ruleService *Rule, userID primitive.ObjectID, options ...RuleFilterOption) RuleFilter

NewRuleFilter returns a fully initialized RuleFilter that is keyed to a specific User.

func (*RuleFilter) Allow added in v0.6.0

func (filter *RuleFilter) Allow(document *streams.Document) bool

Allow returns TRUE if this document is allowed past all User and Domain filters. The document is passed as a pointer because it MAY BE MODIFIED by the filter, for instance, to add a label or other metadata.

func (*RuleFilter) AllowSend added in v0.6.0

func (filter *RuleFilter) AllowSend(actorID string) bool

AllowSend returns TRUE if this actorID is allowed to receive messages.

func (*RuleFilter) Channel added in v0.6.0

func (filter *RuleFilter) Channel(ch <-chan streams.Document) <-chan streams.Document

Channel returns a channel of all documents that are allowed by User/Domain filters. Documents may be modified by filters in the process, for instance, to add content warning labels.

func (*RuleFilter) ChannelSend added in v0.6.0

func (filter *RuleFilter) ChannelSend(ch <-chan model.Follower) <-chan string

ChannelSend inspects the channel of recipients to see if they should receive messages or not.

func (*RuleFilter) Disallow added in v0.6.0

func (filter *RuleFilter) Disallow(document *streams.Document) bool

Disallow returns TRUE if a document is NOT allowed past all User and Domain filters.

func (*RuleFilter) Slice added in v0.6.0

func (filter *RuleFilter) Slice(documents []streams.Document) []streams.Document

Slice returns a slice of all documents from the input that are allowed by User/Domain filters. Documents may be modified by filters in the process, for instance, to add content warning labels.

type RuleFilterOption added in v0.6.0

type RuleFilterOption func(*RuleFilter)

RuleFilterOption defines a functional option that modifies the behavior of a RuleFilter object

func IgnoreBlocks added in v0.6.0

func IgnoreBlocks() RuleFilterOption

IgnoreBlocks returns a RuleFilterOption that prevents `Block` -type rules from being executed

func IgnoreLabels added in v0.6.0

func IgnoreLabels() RuleFilterOption

IgnoreLabels returns a RuleFilterOption that prevents `Label` -type rules from being executed

func IgnoreMutes added in v0.6.0

func IgnoreMutes() RuleFilterOption

IgnoreMutes returns a RuleFilterOption that prevents `Mute` -type rules from being executed

func WithBlocksOnly added in v0.6.0

func WithBlocksOnly() RuleFilterOption

WithLabelsOnly returns a RuleFilterOption that allows ONLY `Block` -type rules, and ignores all others.

func WithLabelsOnly added in v0.6.0

func WithLabelsOnly() RuleFilterOption

WithLabelsOnly returns a RuleFilterOption that allows ONLY `Label` -type rules, and ignores all others.

func WithMutesOnly added in v0.6.0

func WithMutesOnly() RuleFilterOption

WithLabelsOnly returns a RuleFilterOption that allows ONLY `Mute` -type rules, and ignores all others.

type RuleJSONLDGetter added in v0.6.0

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

RuleJSONLDGetter wraps the Rule service and a model.Rule to provide a JSONLDGetter interface

func NewRuleJSONLDGetter added in v0.6.0

func NewRuleJSONLDGetter(service *Rule, rule model.Rule) RuleJSONLDGetter

NewRuleJSONLDGetter returns a fully initialized RuleJSONLDGetter

func (RuleJSONLDGetter) Created added in v0.6.0

func (getter RuleJSONLDGetter) Created() int64

Created returns the creation date of the wrapped Rule

func (RuleJSONLDGetter) GetJSONLD added in v0.6.0

func (getter RuleJSONLDGetter) GetJSONLD() mapof.Any

GetJSONLD returns a JSON-LD representation of the wrapped Rule

type Scheduler

type Scheduler struct {
}

type ServerEmail

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

func NewServerEmail

func NewServerEmail(filesystemService Filesystem, funcMap template.FuncMap, locations []mapof.String) ServerEmail

func (*ServerEmail) Refresh

func (service *ServerEmail) Refresh(locations sliceof.Object[mapof.String])

func (*ServerEmail) Send

func (service *ServerEmail) Send(smtpConnection config.SMTPConnection, templateName string, from string, to []string, subject string, data any) error

type SterankoUserService

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

SterankoUserService is a wrapper/adapter that makes the User service compatable with Steranko.

func NewSterankoUserService

func NewSterankoUserService(userService *User, domainEmail *DomainEmail) SterankoUserService

NewSterankoUserService returns a fully populated SterankoUserService.

func (SterankoUserService) Close

func (service SterankoUserService) Close()

Close is required to implement the steranko.UserService interface

func (SterankoUserService) Delete

func (service SterankoUserService) Delete(user steranko.User, comment string) error

Delete removes a single User from the database

func (SterankoUserService) Load

func (service SterankoUserService) Load(username string, result steranko.User) error

Load retrieves a single User from the database

func (SterankoUserService) New

func (service SterankoUserService) New() steranko.User

New creates a newly initialized User that is ready to use

func (SterankoUserService) NewClaims

func (service SterankoUserService) NewClaims() jwt.Claims

NewClaims creates a new JWT claim object

func (SterankoUserService) RequestPasswordReset

func (service SterankoUserService) RequestPasswordReset(user steranko.User) error

RequestPasswordReset is not currently implemented in this service. (TODO)

func (SterankoUserService) Save

func (service SterankoUserService) Save(user steranko.User, comment string) error

Save inserts/updates a single User in the database

type Stream

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

Stream manages all interactions with the Stream collection

func NewStream

func NewStream() Stream

NewStream returns a fully populated Stream service.

func (*Stream) ActivityPubActor added in v0.6.0

func (service *Stream) ActivityPubActor(streamID primitive.ObjectID, withFollowers bool) (outbox.Actor, error)

ActivityPubActor returns an ActivityPub Actor object ** WHICH INCLUDES ENCRYPTION KEYS ** for the provided Stream.

func (*Stream) ActivityPubURL added in v0.6.0

func (service *Stream) ActivityPubURL(streamID primitive.ObjectID) string

func (*Stream) CalcContext added in v0.6.0

func (service *Stream) CalcContext(stream *model.Stream)

CalcContext calculates the conversational context for a given stream, IF it can be determined.

func (*Stream) CalcParentIDs added in v0.6.0

func (service *Stream) CalcParentIDs(stream *model.Stream) error

CalcParentIDs scans the parent chain of a stream and generates a "breadcrumbs" slice of all of this Stream's parents

func (*Stream) CalcTags added in v0.6.0

func (service *Stream) CalcTags(stream *model.Stream)

func (*Stream) Close

func (service *Stream) Close()

Close stops any background processes controlled by this service

func (*Stream) Count

func (service *Stream) Count(criteria exp.Expression) (int64, error)

Count returns the number of (non-deleted) records in the Stream collection

func (*Stream) Delete

func (service *Stream) Delete(stream *model.Stream, note string) error

Delete removes an Stream from the database (virtual delete)

func (*Stream) DeleteByParent

func (service *Stream) DeleteByParent(parentID primitive.ObjectID, note string) error

func (*Stream) DeleteMany

func (service *Stream) DeleteMany(criteria exp.Expression, note string) error

DeleteMany removes all child streams from the provided stream (virtual delete)

func (*Stream) DeleteRelatedDuplicate

func (service *Stream) DeleteRelatedDuplicate(parentID primitive.ObjectID, originalStreamID primitive.ObjectID) error

Delete RelatedDuplicate hard deletes any inbox/outbox streams that point to the same original.

func (*Stream) JSONLD added in v0.6.0

func (service *Stream) JSONLD(stream *model.Stream) mapof.Any

GetJSONLD returns a map document that conforms to the ActivityStreams 2.0 spec. This map will still need to be marshalled into JSON

func (*Stream) JSONLDGetter added in v0.6.0

func (service *Stream) JSONLDGetter(stream *model.Stream) StreamJSONLDGetter

JSONLDGetter returns a new JSONLDGetter for the provided stream

func (*Stream) List

func (service *Stream) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Streams that match the provided criteria

func (*Stream) ListByParent

func (service *Stream) ListByParent(parentID primitive.ObjectID) (data.Iterator, error)

ListByParent returns all Streams that match a particular parentID

func (*Stream) ListByTemplate

func (service *Stream) ListByTemplate(template string) (data.Iterator, error)

ListByTemplate returns all `Streams` that use a particular `Template`

func (*Stream) ListNavigation

func (service *Stream) ListNavigation() (data.Iterator, error)

ListNavigation returns all Streams of type FOLDER at the top of the hierarchy

func (*Stream) Load

func (service *Stream) Load(criteria exp.Expression, stream *model.Stream) error

Load retrieves an Stream from the database

func (*Stream) LoadByID

func (service *Stream) LoadByID(streamID primitive.ObjectID, result *model.Stream) error

LoadByID returns a single `Stream` that matches the provided streamID

func (*Stream) LoadByToken

func (service *Stream) LoadByToken(token string, result *model.Stream) error

LoadByToken returns a single `Stream` that matches a particular `Token`

func (*Stream) LoadByURL

func (service *Stream) LoadByURL(streamURL string, result *model.Stream) error

LoadByURL returns a single `Stream` that matches the provided URL

func (*Stream) LoadFirstAttachment

func (service *Stream) LoadFirstAttachment(streamID primitive.ObjectID) (model.Attachment, error)

func (*Stream) LoadFirstSibling

func (service *Stream) LoadFirstSibling(parentID primitive.ObjectID, result *model.Stream) error

func (*Stream) LoadLastSibling

func (service *Stream) LoadLastSibling(parentID primitive.ObjectID, result *model.Stream) error

func (*Stream) LoadNavigationByID

func (service *Stream) LoadNavigationByID(streamID primitive.ObjectID, result *model.Stream) error

LoadNavigationByID locates a single stream in the top level of the site hierarchy

func (*Stream) LoadNextSibling

func (service *Stream) LoadNextSibling(parentID primitive.ObjectID, rank int, result *model.Stream) error

func (*Stream) LoadParent

func (service *Stream) LoadParent(stream *model.Stream, parent *model.Stream) error

LoadParent returns the Stream that is the parent of the provided Stream

func (*Stream) LoadPrevSibling

func (service *Stream) LoadPrevSibling(parentID primitive.ObjectID, rank int, result *model.Stream) error

func (*Stream) LoadWebFinger

func (service *Stream) LoadWebFinger(token string) (digit.Resource, error)

func (*Stream) LoadWithOptions

func (service *Stream) LoadWithOptions(criteria exp.Expression, result *model.Stream, options ...option.Option) error

func (*Stream) MaxRank

func (service *Stream) MaxRank(parentID primitive.ObjectID) (int, error)

MaxRank returns the maximum rank of all children of a stream

func (*Stream) New

func (service *Stream) New() model.Stream

New returns a new Stream that uses the named template.

func (*Stream) ObjectDelete

func (service *Stream) ObjectDelete(object data.Object, note string) error

func (*Stream) ObjectID

func (service *Stream) ObjectID(object data.Object) primitive.ObjectID

func (*Stream) ObjectList

func (service *Stream) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*Stream) ObjectLoad

func (service *Stream) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*Stream) ObjectNew

func (service *Stream) ObjectNew() data.Object

New returns a fully initialized model.Stream as a data.Object.

func (*Stream) ObjectQuery

func (service *Stream) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*Stream) ObjectSave

func (service *Stream) ObjectSave(object data.Object, note string) error

func (*Stream) ObjectType

func (service *Stream) ObjectType() string

ObjectType returns the type of object that this service manages

func (*Stream) ObjectUserCan

func (service *Stream) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*Stream) ParsePath added in v0.6.0

func (service *Stream) ParsePath(uri *url.URL) (string, string, error)

ParsePathextracts the Stream token and actionID from a URL

func (*Stream) ParseURL added in v0.6.0

func (service *Stream) ParseURL(streamURL string) (primitive.ObjectID, error)

ParseURL validates that a URL matches the current server, and then extracts the streamID from it.

func (*Stream) Publish added in v0.6.0

func (service *Stream) Publish(user *model.User, stream *model.Stream) error

Publish marks this stream as "published"

func (*Stream) PurgeDeleted

func (service *Stream) PurgeDeleted(ancestorID primitive.ObjectID) error

PurgeDeleted hard deletes all items with the given ancestor that have already been soft-deleted

func (*Stream) Query

func (service *Stream) Query(criteria exp.Expression, options ...option.Option) ([]model.Stream, error)

Query returns an slice containing all of the Streams that match the provided criteria

func (*Stream) QueryByAncestorAndDate added in v0.6.0

func (service *Stream) QueryByAncestorAndDate(streamID primitive.ObjectID, publishedDate int64, pageSize int) ([]model.Stream, error)

QueryByParentAndDate returns a slice of Streams that are ANY DEPTH below the provided StreamID

func (*Stream) QueryByParentAndDate added in v0.6.0

func (service *Stream) QueryByParentAndDate(streamID primitive.ObjectID, publishedDate int64, pageSize int) ([]model.Stream, error)

QueryByParentAndDate returns a slice of Streams that are DIRECT CHILDREN of the provided StreamID

func (*Stream) QueryByUser added in v0.6.0

func (service *Stream) QueryByUser(userID primitive.ObjectID, criteria exp.Expression, options ...option.Option) ([]model.Stream, error)

func (*Stream) QuerySummary

func (service *Stream) QuerySummary(criteria exp.Expression, options ...option.Option) ([]model.StreamSummary, error)

QuerySummary returns an slice containing StreamSummaries for all of the Streams that match the provided criteria

func (*Stream) Refresh

func (service *Stream) Refresh(collection data.Collection, templateService *Template, draftService *StreamDraft, outboxService *Outbox, attachmentService *Attachment, activityService *ActivityStream, contentService *Content, keyService *EncryptionKey, followerService *Follower, ruleService *Rule, userService *User, host string, streamUpdateChannel chan model.Stream)

Refresh updates any stateful data that is cached inside this service.

func (*Stream) RestoreDeleted

func (service *Stream) RestoreDeleted(ancestorID primitive.ObjectID) error

RestoreDeleted un-deletes all soft-deleted records underneath a common ancestor.

func (*Stream) Save

func (service *Stream) Save(stream *model.Stream, note string) error

Save adds/updates an Stream in the database

func (*Stream) Schema

func (service *Stream) Schema() schema.Schema

func (*Stream) SetLocationChild added in v0.6.0

func (service *Stream) SetLocationChild(template *model.Template, stream *model.Stream, parent *model.Stream) error

SetLocationChild sets a Stream to be a child of another Stream

func (*Stream) SetLocationOutbox added in v0.6.0

func (service *Stream) SetLocationOutbox(template *model.Template, stream *model.Stream, userID primitive.ObjectID) error

SetLocationInbox sets a Stream's location to be a User's outbox

func (*Stream) SetLocationTop added in v0.6.0

func (service *Stream) SetLocationTop(template *model.Template, stream *model.Stream) error

SetLocationTop sets a Stream to be a top-level navigation item

func (*Stream) Startup added in v0.6.0

func (service *Stream) Startup(theme *model.Theme) error

func (*Stream) UnPublish added in v0.6.0

func (service *Stream) UnPublish(user *model.User, stream *model.Stream) error

UnPublish marks this stream as "published"

func (*Stream) UserCan added in v0.6.0

func (service *Stream) UserCan(authorization *model.Authorization, stream *model.Stream, actionID string) error

UserCan checks a user's permission to perform an action on a Stream. If not allowed, then the returned error describes why the access was denied.

type StreamDraft

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

StreamDraft manages all interactions with the StreamDraft collection

func NewStreamDraft

func NewStreamDraft() StreamDraft

NewStreamDraft returns a fully populated StreamDraft service.

func (*StreamDraft) Close

func (service *StreamDraft) Close()

Close stops any background processes controlled by this service

func (*StreamDraft) Delete

func (service *StreamDraft) Delete(draft *model.Stream, _note string) error

Delete removes an StreamDraft from the database (hard delete)

func (*StreamDraft) Load

func (service *StreamDraft) Load(criteria exp.Expression, result *model.Stream) error

Load either: 1) loads a valid draft from the database, or 2) creates a new draft and returns it instead

func (*StreamDraft) LoadByID

func (service *StreamDraft) LoadByID(streamID primitive.ObjectID, result *model.Stream) error

LoadByID returns a single Stream that matches a particular StreamID

func (*StreamDraft) New

func (service *StreamDraft) New() model.Stream

New creates a newly initialized StreamDraft that is ready to use

func (*StreamDraft) ObjectDelete

func (service *StreamDraft) ObjectDelete(object data.Object, comment string) error

func (*StreamDraft) ObjectID

func (service *StreamDraft) ObjectID(object data.Object) primitive.ObjectID

func (*StreamDraft) ObjectList

func (service *StreamDraft) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*StreamDraft) ObjectLoad

func (service *StreamDraft) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*StreamDraft) ObjectNew

func (service *StreamDraft) ObjectNew() data.Object

New returns a fully initialized model.Stream as a data.Object.

func (*StreamDraft) ObjectQuery

func (service *StreamDraft) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*StreamDraft) ObjectSave

func (service *StreamDraft) ObjectSave(object data.Object, comment string) error

func (*StreamDraft) ObjectType

func (service *StreamDraft) ObjectType() string

ObjectType returns the type of object that this service manages

func (*StreamDraft) ObjectUserCan

func (service *StreamDraft) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*StreamDraft) Promote

func (service *StreamDraft) Promote(streamID primitive.ObjectID, stateID string) (model.Stream, error)

func (*StreamDraft) Refresh

func (service *StreamDraft) Refresh(collection data.Collection, streamService *Stream)

Refresh updates any stateful data that is cached inside this service.

func (*StreamDraft) Save

func (service *StreamDraft) Save(draft *model.Stream, note string) error

save adds/updates an StreamDraft in the database

func (*StreamDraft) Schema

func (service *StreamDraft) Schema() schema.Schema

type StreamJSONLDGetter added in v0.6.0

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

StreamJSONLDGetter wraps the Stream service and a model.Stream to provide a JSONLDGetter interface

func NewStreamJSONLDGetter added in v0.6.0

func NewStreamJSONLDGetter(streamService *Stream, stream *model.Stream) StreamJSONLDGetter

NewStreamJSONLDGetter returns a fully initialized StreamJSONLDGetter

func (StreamJSONLDGetter) Created added in v0.6.0

func (getter StreamJSONLDGetter) Created() int64

Created returns the creation date of the wrapped Stream

func (StreamJSONLDGetter) GetJSONLD added in v0.6.0

func (getter StreamJSONLDGetter) GetJSONLD() mapof.Any

GetJSONLD returns a JSON-LD representation of the wrapped Stream

type TaskCreateWebSubFollower added in v0.6.0

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

func NewTaskCreateWebSubFollower added in v0.6.0

func NewTaskCreateWebSubFollower(followerService *Follower, locatorService Locator, objectType string, objectID primitive.ObjectID, format string, mode string, topic string, callback string, secret string, leaseSeconds int) TaskCreateWebSubFollower

func (TaskCreateWebSubFollower) Run added in v0.6.0

func (task TaskCreateWebSubFollower) Run() error

type TaskReceiveWebMention added in v0.6.0

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

func NewTaskReceiveWebMention added in v0.6.0

func NewTaskReceiveWebMention(streamService *Stream, mentionService *Mention, userService *User, source string, target string) TaskReceiveWebMention

func (TaskReceiveWebMention) Run added in v0.6.0

func (task TaskReceiveWebMention) Run() error

type TaskSendWebMention added in v0.6.0

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

func NewTaskSendWebMention added in v0.6.0

func NewTaskSendWebMention(source string, target string) TaskSendWebMention

func (TaskSendWebMention) Run added in v0.6.0

func (task TaskSendWebMention) Run() error

type TaskSendWebSubMessage added in v0.6.0

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

TaskSendWebSubMessage sends a WebSub notification to a single WebSub follower.

func NewTaskSendWebSubMessage added in v0.6.0

func NewTaskSendWebSubMessage(follower model.Follower) TaskSendWebSubMessage

func (TaskSendWebSubMessage) Run added in v0.6.0

func (task TaskSendWebSubMessage) Run() error

type Template

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

Template service manages all of the templates in the system, and merges them with data to form fully populated HTML pages.

func NewTemplate

func NewTemplate(filesystemService Filesystem, themeService *Theme, widgetService *Widget, funcMap template.FuncMap, locations []mapof.String) *Template

NewTemplate returns a fully initialized Template service.

func (*Template) Add

func (service *Template) Add(templateID string, filesystem fs.FS, definition []byte) error

func (*Template) List

func (service *Template) List(filter func(*model.Template) bool) []form.LookupCode

List returns all templates that match the provided criteria

func (*Template) ListByContainer

func (service *Template) ListByContainer(containedByRole string) []form.LookupCode

ListByContainer returns all model.Templates that match the provided "containedByRole" value

func (*Template) ListByContainerLimited

func (service *Template) ListByContainerLimited(containedByRole string, limitRoles sliceof.String) []form.LookupCode

ListByContainerLimited returns all model.Templates that match the provided "containedByRole" value AND whose TemplateRoles are present in the "limitRoles" list. If the "limited" list is empty, then all otherwise-valid templates are returned.

func (*Template) Load

func (service *Template) Load(templateID string) (model.Template, error)

Load retrieves an Template from the database

func (*Template) LoadAdmin

func (service *Template) LoadAdmin(templateID string) (model.Template, error)

func (*Template) Refresh

func (service *Template) Refresh(locations sliceof.Object[mapof.String])

func (*Template) Schema

func (service *Template) Schema(templateID string) (schema.Schema, error)

Schema returns the Schema associated with this Stream

func (*Template) State

func (service *Template) State(templateID string, stateID string) (model.State, error)

State returns the detailed State information associated with this Stream

type Theme

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

Theme service manages the global site theme that is stored in a particular path of the filesystem.

func NewTheme

func NewTheme(templateService *Template, contentService *Content, funcMap template.FuncMap) *Theme

NewTheme returns a fully initialized Theme service.

func (*Theme) Add

func (service *Theme) Add(themeID string, filesystem fs.FS, definition []byte) error

func (*Theme) GetTheme

func (service *Theme) GetTheme(themeID string) model.Theme

func (*Theme) List

func (service *Theme) List() []model.Theme

func (*Theme) ListActive added in v0.6.0

func (service *Theme) ListActive() []model.Theme

func (*Theme) ListSorted added in v0.6.0

func (service *Theme) ListSorted() []model.Theme

type ThemeLookupProvider

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

func NewThemeLookupProvider

func NewThemeLookupProvider(themeService *Theme) ThemeLookupProvider

func (ThemeLookupProvider) Get

func (service ThemeLookupProvider) Get() []form.LookupCode

type User

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

User manages all interactions with the User collection

func NewUser

func NewUser() User

NewUser returns a fully populated User service

func (*User) ActivityPubActor

func (service *User) ActivityPubActor(userID primitive.ObjectID, withFollowers bool) (outbox.Actor, error)

ActivityPubActor returns an ActivityPub Actor object ** WHICH INCLUDES ENCRYPTION KEYS ** for the provided User.

func (*User) ActivityPubPublicKeyURL

func (service *User) ActivityPubPublicKeyURL(userID primitive.ObjectID) string

func (*User) ActivityPubURL

func (service *User) ActivityPubURL(userID primitive.ObjectID) string

func (*User) CalcFollowerCount

func (service *User) CalcFollowerCount(userID primitive.ObjectID)

func (*User) CalcFollowingCount

func (service *User) CalcFollowingCount(userID primitive.ObjectID)

func (*User) CalcRuleCount added in v0.6.0

func (service *User) CalcRuleCount(userID primitive.ObjectID)

func (*User) Close

func (service *User) Close()

Close stops any background processes controlled by this service

func (*User) Count

func (service *User) Count(ctx context.Context, criteria exp.Expression) (int64, error)

Count returns the number of (non-deleted) records in the User collection

func (*User) Delete

func (service *User) Delete(user *model.User, note string) error

Delete removes an User from the database (virtual delete)

func (*User) DeleteAvatar added in v0.6.0

func (service *User) DeleteAvatar(user *model.User, note string) error

func (*User) List

func (service *User) List(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

List returns an iterator containing all of the Users who match the provided criteria

func (*User) ListByGroup

func (service *User) ListByGroup(group string) (data.Iterator, error)

ListByGroup returns all users that match a provided group name

func (*User) ListByIdentities

func (service *User) ListByIdentities(identities []string) (data.Iterator, error)

ListByIdentities returns all users that appear in the list of identities

func (*User) ListOwners

func (service *User) ListOwners() (data.Iterator, error)

func (*User) ListOwnersAsSlice

func (service *User) ListOwnersAsSlice() []model.UserSummary

func (*User) ListUsernameOrOwner added in v0.6.0

func (service *User) ListUsernameOrOwner(username string) (data.Iterator, error)

func (*User) Load

func (service *User) Load(criteria exp.Expression, result *model.User) error

Load retrieves an User from the database

func (*User) LoadByID

func (service *User) LoadByID(userID primitive.ObjectID, result *model.User) error

LoadByID loads a single model.User object that matches the provided userID

func (*User) LoadByProfileURL added in v0.6.0

func (service *User) LoadByProfileURL(profileUrl string, result *model.User) error

func (*User) LoadByResetCode

func (service *User) LoadByResetCode(userID string, code string, user *model.User) error

func (*User) LoadByToken

func (service *User) LoadByToken(token string, result *model.User) error

LoadByUsername loads a single model.User object that matches the provided token

func (*User) LoadByUsername

func (service *User) LoadByUsername(username string, result *model.User) error

LoadByUsername loads a single model.User object that matches the provided username

func (*User) LoadByUsernameOrEmail

func (service *User) LoadByUsernameOrEmail(usernameOrEmail string, result *model.User) error

LoadByUsernameOrEmail loads a single model.User object that matches the provided username

func (*User) LoadWebFinger

func (service *User) LoadWebFinger(username string) (digit.Resource, error)

func (*User) MakeNewPasswordResetCode

func (service *User) MakeNewPasswordResetCode(user *model.User) error

MakeNewPasswordResetCode generates a new password reset code for the provided user.

func (*User) ObjectDelete

func (service *User) ObjectDelete(object data.Object, note string) error

func (*User) ObjectID

func (service *User) ObjectID(object data.Object) primitive.ObjectID

func (*User) ObjectList

func (service *User) ObjectList(criteria exp.Expression, options ...option.Option) (data.Iterator, error)

func (*User) ObjectLoad

func (service *User) ObjectLoad(criteria exp.Expression) (data.Object, error)

func (*User) ObjectNew

func (service *User) ObjectNew() data.Object

New returns a fully initialized model.Stream as a data.Object.

func (*User) ObjectQuery

func (service *User) ObjectQuery(result any, criteria exp.Expression, options ...option.Option) error

func (*User) ObjectSave

func (service *User) ObjectSave(object data.Object, note string) error

func (*User) ObjectType

func (service *User) ObjectType() string

ObjectType returns the type of object that this service manages

func (*User) ObjectUserCan

func (service *User) ObjectUserCan(object data.Object, authorization model.Authorization, action string) error

func (*User) ParseProfileURL

func (service *User) ParseProfileURL(value string) (primitive.ObjectID, error)

ParseProfileURL parses (or looks up) the correct UserID from a given URL. Unlike the package-level ParseProfileURL, this method can resolve usernames into objectIDs because it has access to the database server.

func (*User) Query added in v0.6.0

func (service *User) Query(criteria exp.Expression, options ...option.Option) ([]model.User, error)

Query returns an slice containing all of the Users who match the provided criteria

func (*User) QueryBlockedActors added in v0.6.0

func (service *User) QueryBlockedActors(userID primitive.ObjectID, criteria exp.Expression) ([]model.User, error)

TODO: MEDIUM: this function is wickedly inefficient Should probably use a RuleFilter here.

func (*User) Refresh

func (service *User) Refresh(userCollection data.Collection, followerCollection data.Collection, followingCollection data.Collection, ruleCollection data.Collection, attachmentService *Attachment, ruleService *Rule, emailService *DomainEmail, keyService *EncryptionKey, folderService *Folder, followerService *Follower, streamService *Stream, host string)

Refresh updates any stateful data that is cached inside this service.

func (*User) RemoteFollowURL

func (service *User) RemoteFollowURL() string

func (*User) Save

func (service *User) Save(user *model.User, note string) error

Save adds/updates an User in the database

func (*User) Schema

func (service *User) Schema() schema.Schema

func (*User) SendPasswordResetEmail

func (service *User) SendPasswordResetEmail(user *model.User)

SendPasswordResetEmail generates a new password reset code and sends a welcome email to a new user. If there is a problem sending the email, then the new code is not saved.

func (*User) SendWelcomeEmail

func (service *User) SendWelcomeEmail(user *model.User)

SendWelcomeEmail generates a new password reset code and sends a welcome email to a new user. If there is a problem sending the email, then the new code is not saved.

func (*User) SetOwner

func (service *User) SetOwner(owner config.Owner) error

type Widget

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

Widget service manages the global, in-memory library of widget templates that can be applied to any Stream

func NewWidget

func NewWidget(funcMap template.FuncMap) *Widget

NewWidget returns a fully initialized Widget service.

func (*Widget) Add

func (service *Widget) Add(widgetID string, filesystem fs.FS, definition []byte) error

Add loads a widget definition from a filesystem, and adds it to the in-memory library.

func (*Widget) Get

func (service *Widget) Get(widgetID string) (model.Widget, bool)

Get returns a widget definition from the in-memory library.

func (*Widget) IsValidWidgetType

func (service *Widget) IsValidWidgetType(widgetType string) bool

func (*Widget) List

func (service *Widget) List() []form.LookupCode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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