model

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

Documentation

Overview

Package model contains all of the domain model objects that are used in the system. Model objects map loosely to the concept of "Entities" outlined in the "Clean Architecture" design pattern (https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html),so model objects do not contain business logic -- only pure data and limited functionality (such as validation). Database access, business logic, and other more advanced features are handled by the service package.

Index

Constants

View Source
const AttachmentTypeStream = "Stream"

AttachmentTypeStream represents an attachment that is owned by a Stream

View Source
const AttachmentTypeUser = "User"

AttachmentTypeUser represents an attachment that is owned by a User

View Source
const ContentFormatEditorJS = "EDITORJS"

ContentFormatEditorJS represents a content object whose Raw value is defined in EditorJS This content must be converted into HTML before being used in a browser See: https://editorjs.io

View Source
const ContentFormatHTML = "HTML"

ContentFormatHTML represents a content object whose Raw value is defined in HTML This content can be used in a browser (after passing through a safety filter like BlueMonday)

View Source
const ContentFormatMarkdown = "MARKDOWN"

ContentFormatContentJS represents a content object whose Raw value is defined in Markdown This content must be converted into HTML before being used in a browser See: https://commonmark.org

View Source
const ContentFormatText = "TEXT"

ContentFormatText represents a content object whose Raw value is defined in plain text. This content must be converted into HTML before being used in a browser

View Source
const EncryptionKeyEncodingPlaintext = "plaintext"
View Source
const EncryptionKeyTypeStream = "Stream"

EncryptionKeyTypeStream identifies an EncryptionKey that is owned by a Stream/Actor

View Source
const EncryptionKeyTypeUser = "User"

EncryptionKeyTypeUser identifies an EncryptionKey that is owned by a User/Actor

View Source
const FolderFilterAll = "ALL"
View Source
const FolderFilterUnread = "UNREAD"
View Source
const FolderLayoutChat = "CHAT"
View Source
const FolderLayoutMagazine = "MAGAZINE"
View Source
const FolderLayoutNewspaper = "NEWSPAPER"
View Source
const FolderLayoutSocial = "SOCIAL"
View Source
const FollowMethodActivityPub = "ACTIVITYPUB"

FollowMethodActivityPub represents the ActivityPub subscription https://www.w3.org/TR/activitypub/

View Source
const FollowMethodPoll = "POLL"

FollowMethodPoll represents a subscription that must be polled for updates

View Source
const FollowMethodRssCloud = "RSSCLOUD"
View Source
const FollowMethodWebSub = "WEBSUB"

FollowMethodWebSub represents a WebSub subscription https://websub.rocks

View Source
const FollowerTypeStream = "Stream"

FollowerTypeStream represents a Follower that is following a Stream

View Source
const FollowerTypeUser = "User"

FollowerTypeUser represents a Follower that is following a User

View Source
const FollowingBehaviorPosts = "POSTS"

FollowingBehaviorPosts declares that only Posts (not Replies) should be imported from a followed account

View Source
const FollowingBehaviorPostsAndReplies = "POSTS+REPLIES"

FollowingBehaviorPostsAndReplies declares that all messages (both Posts and Replies) should be imported from a followed account

View Source
const FollowingRuleActionBlock = "BLOCK"

FollowingRuleActionBlock declares that Rules published by a followed account should be blocked

View Source
const FollowingRuleActionIgnore = "IGNORE"

FollowingRuleActionIgnore declares that Rules published by a followed account should be ignored

View Source
const FollowingRuleActionLabel = "LABEL"

FollowingRuleActionLabel declares that Rules published by a followed account should be labeled with content provided by the followed account.

View Source
const FollowingRuleActionMute = "MUTE"

FollowingRuleActionMute declares that Rules published by a followed account should be muted

View Source
const FollowingStatusFailure = "FAILURE"

FollowingStatusFailure represents a following that has failed to load

View Source
const FollowingStatusLoading = "LOADING"

FollowingStatusLoading represents a following that is being loaded for the first time

View Source
const FollowingStatusNew = "NEW"

FollowingStatusNew represents a new following that has not yet been polled

View Source
const FollowingStatusSuccess = "SUCCESS"

FollowingStatusSuccess represents a following that has successfully loaded

View Source
const LinkRelationAlternate = "alternate"

LinkRelationAlternate refers to an alternate format of the current document https://html.spec.whatwg.org/multipage/links.html#link-type-alternate

View Source
const LinkRelationAuthor = "author"

LinkRelationAuthor refers to the context's author. https://html.spec.whatwg.org/multipage/links.html#link-type-author

View Source
const LinkRelationBookmark = "bookmark"

LinkRelationBookmark gives a permanent link to use for bookmarking purposes https://html.spec.whatwg.org/multipage/links.html#link-type-bookmark

View Source
const LinkRelationHub = "hub"

LinkRelationHub is a link to a WebSub hub https://www.w3.org/TR/websub/#discovery

View Source
const LinkRelationIcon = "icon"

LinkRelationIcon indicates an icon for the current document https://html.spec.whatwg.org/multipage/links.html#rel-icon

View Source
const LinkRelationInReplyTo = "in-reply-to"

LinkRelationInReplyTo indicates that this document is a reply to another document https://www.rfc-editor.org/rfc/rfc4685.html

View Source
const LinkRelationOriginal = "original"

LinkRelationOriginal points to an Original Resource. https://www.rfc-editor.org/rfc/rfc7089.html#section-2.2.1

View Source
const LinkRelationProfile = "profile"

LinkRelationProfile refers to the context's author. https://www.rfc-editor.org/rfc/rfc6906.html

View Source
const LinkRelationSelf = "self"

LinkRelationSelf refers to the context's author. https://html.spec.whatwg.org/multipage/links.html#link-type-self

View Source
const LinkSourceActivityPub = "ACTIVITYPUB"

LinkSourceActivityPub indicates that this linked document was generated by an ActivityPub source

View Source
const LinkSourceInternal = "INTERNAL"

LinkSourceInternal indicates that this linked document was generated by Emissary

View Source
const LinkSourceRSS = "RSS"

LinkSourceRSS indicates that that this linked document was generated by an RSS Feed

View Source
const LinkSourceTwitter = "TWITTER"

LinkSourceTwitter indicates that this linked document was generated by Twitter

View Source
const MagicMimeTypeWebSub = "MAGIC-MIME-TYPE-WEBSUB"
View Source
const MagicRoleAnonymous = "anonymous"

MagicRoleAnonymous grants permissions to a user who has not been signed in.

View Source
const MagicRoleAuthenticated = "authenticated"

MagicRoleAuthenticated grants permissions to a user who has been signed in, regardless of any other group roles.

View Source
const MagicRoleAuthor = "author"

MagicRoleAuthor grants permissions to the user who originally created a stream

View Source
const MagicRoleMyself = "self"

MagicRoleMyself grants permissions to a user who is trying to access their own profile.

View Source
const MagicRoleOwner = "owner"

MagicRoleOwner grants full access to a user with database owner privileges

View Source
const MentionStatusInvalid = "INVALID"

MentionStatusInvalid represents a Mention that is not valid

View Source
const MentionStatusPending = "PENDING"

MentionStatusPending represents a Mention that has not yet been validated

View Source
const MentionStatusValidated = "VALIDATED"

MentionStatusValidated represents a Mention that has been validated

View Source
const MentionTypeStream = "Stream"

MentionTypeStream represents a Mention that references a Stream record

View Source
const MentionTypeUser = "User"

MentionTypeUser represents a Mention that references a User record

View Source
const MessageStateMuted = "MUTED"

MessageStateMuted labels a message that has been read by its owner and marked as "Muted". If additional replies are received for this messages, it will NOT be re-displayed in their inbox.

View Source
const MessageStateNewReplies = "NEW-REPLIES"

MessageStateNewReplies labels a message that has been read by its owner, and is now being re-displayed in their inbox because new replies have been received.

View Source
const MessageStateRead = "READ"

MessageStateRead labels a message that has been read by its owner. If additional replies are recieved for this message, it will be re-displayed in their inbox.

View Source
const MessageStateUnmuted = "UNMUTED"

MessageStateUnmuted is a magic state that is used to reset a message's MUTE status.

View Source
const MessageStateUnread = "UNREAD"

MessageStateNew labels a message that has been received but not yet read by its owner

View Source
const MimeTypeActivityPub = "application/activity+json"
View Source
const MimeTypeAtom = "application/atom+xml"
View Source
const MimeTypeEventStream = "text/event-stream"
View Source
const MimeTypeHTML = "text/html"
View Source
const MimeTypeImage = "image/*"
View Source
const MimeTypeJSON = "application/json"
View Source
const MimeTypeJSONFeed = "application/feed+json"
View Source
const MimeTypeJSONLD = "application/ld+json"
View Source
const MimeTypeJSONResourceDescriptor = "application/jrd+json"
View Source
const MimeTypeRSS = "application/rss+xml"
View Source
const MimeTypeXML = "application/xml"
View Source
const MimeTypeXMLText = "text/xml"
View Source
const OriginTypeAnnounce = "ANNOUNCE"

OriginTypeAnnounce identifies a link that was retrieved because of a "Announce" of an existing post

View Source
const OriginTypeDislike = "DISLIKE"

OriginTypeBoost identifies a link that was retrieved because of a "Dislike" of an existing post

View Source
const OriginTypeLike = "LIKE"

OriginTypeBoost identifies a link that was retrieved because of a "Like" of an existing post

View Source
const OriginTypePrimary = "PRIMARY"

OriginTypePrimary identifies an original post by an author (not a reply, announce, like, or dislike)

View Source
const OriginTypeReply = "REPLY"

OriginTypeReply identifies a link that was retrieved because of a "Reply" to an existing post

View Source
const RuleActionBlock = "BLOCK"

RuleActionBlock rules all contact with a particular user or domain

View Source
const RuleActionLabel = "LABEL"

RuleActionLabel allows inbound messages but labels them with a custom message

View Source
const RuleActionMute = "MUTE"

RuleActionMute prevents inbound messages from a particular user or domain

View Source
const RuleOriginAdmin = "ADMIN"

RuleOriginAdmin signifies a Rule that was created by a domain administrator

View Source
const RuleOriginRemote = "REMOTE"

RuleOriginRemote signifies a Rule that was imported from a remote actor

View Source
const RuleOriginUser = "USER"

RuleOriginUser signifies a Rule that was created by the user

View Source
const RuleTypeActor = "ACTOR"

RuleTypeUser rules all messages from a specific user

View Source
const RuleTypeContent = "CONTENT"

RuleTypeUser rules all messages that contain a particular phrase (hashtag)

View Source
const RuleTypeDomain = "DOMAIN"

RuleTypeDomain rules all messages that link to a specific domain or URL prefix

View Source
const TagRelationRule = "--emissary-rule"

TagRelationRule identifies a tag that was created by an internal Emissary rule.

Variables

View Source
var MagicGroupIDAnonymous primitive.ObjectID

MagicGroupIDAnonymous refers to a user who has not been signed in. Every user on the Internet is given this group, whether signed in or not. Go won't let us make constant arrays, but consider this variable to be immutable.

View Source
var MagicGroupIDAuthenticated primitive.ObjectID

MaicGroupIDAuthenticated refers to every user who has been signed in, regardless of other permissions, but does not include Anonymous users who are not signed in. Go won't let us make constant arrays, but consider this variable to be immutable.

Functions

func AttachmentSchema

func AttachmentSchema() schema.Element

func ContentSchema

func ContentSchema() schema.Element

ContentSchema returns the JSON Schema for a Content object

func DocumentLinkSchema

func DocumentLinkSchema() schema.Element

func DomainSchema

func DomainSchema() schema.Element

func EncryptionKeySchema

func EncryptionKeySchema() schema.Element

func FolderSchema

func FolderSchema() schema.Element

FolderSchema returns a Rosetta Schema for the Folder object

func FollowerSchema

func FollowerSchema() schema.Element

func FollowerSummaryFields

func FollowerSummaryFields() []string

FollowerSummaryFields returns a slice of all BSON field names for a FollowerSummary

func FollowingSchema

func FollowingSchema() schema.Element

FollowingSchema returns a validating schema for Following objects

func FollowingSummaryFields

func FollowingSummaryFields() []string

FollowingSummaryFields returns a slice of all BSON field names for a FollowingSummary

func GroupFields

func GroupFields() []string

func GroupSchema

func GroupSchema() schema.Element

func MentionSchema

func MentionSchema() schema.Element

func MessageFields added in v0.6.0

func MessageFields() []string

func MessageSchema

func MessageSchema() schema.Element

MessageSchema returns a JSON Schema that describes this object

func NewStreamPermissions

func NewStreamPermissions() mapof.Object[sliceof.String]

NewStreamPermissions returns a fully initialized Permissions object

func NewStreamWidgets

func NewStreamWidgets() set.Slice[StreamWidget]

NewStreamWidgets returns a fully initialized StreamWidget slice

func OAuthClientSchema added in v0.6.0

func OAuthClientSchema() schema.Element

func OAuthUserTokenSchema added in v0.6.0

func OAuthUserTokenSchema() schema.Element

func OriginLinkSchema

func OriginLinkSchema() schema.Element

OriginLinkSchema returns a JSON Schema for OriginLink structures

func OutboxMessageFields added in v0.6.0

func OutboxMessageFields() []string

func OutboxMessageSummaryFields added in v0.6.0

func OutboxMessageSummaryFields() []string

func PasswordResetSchema

func PasswordResetSchema() schema.Element

func PermissionSchema

func PermissionSchema() schema.Element

func PersonLinkProfileURL added in v0.6.0

func PersonLinkProfileURL(person PersonLink) string

PersonLinkProfileURL is a convenience function that returns the profile URL for a PersonLink

func PersonLinkSchema

func PersonLinkSchema() schema.Element

func ResponseSchema added in v0.6.0

func ResponseSchema() schema.Element

func RuleSchema added in v0.6.0

func RuleSchema() schema.Element

func RuleSummaryFields added in v0.6.0

func RuleSummaryFields() []string

RuleSummaryFields returns a list of fields that should be queried from the database when populating a RuleSummary object or collection.

func SignupFormSchema

func SignupFormSchema() schema.Element

func SortThemes added in v0.6.0

func SortThemes(a, b Theme) bool

SortThemes is a sort.Slice function that sorts themes by their label

func StreamSchema

func StreamSchema() schema.Element

func StreamSummaryFields

func StreamSummaryFields() []string

func StreamWidgetSchema

func StreamWidgetSchema() schema.Element

func TagAsJSONLD added in v0.6.0

func TagAsJSONLD(tag Tag) mapof.Any

func TagSchema added in v0.6.0

func TagSchema() schema.Element

func UserSchema

func UserSchema() schema.Element

func UserSummaryFields

func UserSummaryFields() []string

func WidgetSchema

func WidgetSchema() schema.Element

WidgetSchema defines the structure for the "widgets" container.

Types

type Action

type Action struct {
	Roles      []string            `json:"roles"      bson:"roles"`      // List of roles required to execute this Action.  If empty, then none are required.
	States     []string            `json:"states"     bson:"states"`     // List of states required to execute this Action.  If empty, then one are required.
	StateRoles map[string][]string `json:"stateRoles" bson:"stateRoles"` // Map of states -> list of roles that can perform this Action (when a stream is in the given state)
	Steps      []step.Step         `json:"steps"      bson:"steps"`      // List of steps to execute when GET-ing or POST-ing this Action.
}

Action holds the data for actions that can be performed on any Stream from a particular Template.

func NewAction

func NewAction() Action

NewAction returns a fully initialized Action

func (*Action) AllowedRoles

func (action *Action) AllowedRoles(stateID string) []string

AllowedRoles returns a string of all page request roles that are allowed to perform this action. This includes system roles like "anonymous", "authenticated", "self", "author", and "owner".

func (*Action) UnmarshalJSON

func (action *Action) UnmarshalJSON(data []byte) error

func (*Action) UnmarshalMap

func (action *Action) UnmarshalMap(data map[string]any) error

func (*Action) UserCan

func (action *Action) UserCan(enumerator RoleStateEnumerator, authorization *Authorization) bool

UserCan returns TRUE if this action is permitted on a stream (using the provided authorization)

type ActorSummary added in v0.6.0

type ActorSummary struct {
	ID       string `bson:"id"`
	Type     string `bson:"type"`
	Name     string `bson:"name"`
	Icon     string `bson:"icon"`
	Username string `bson:"preferredUsername"`
}

ActorSummary is a record returned by the ActivityStream directory

func (ActorSummary) UsernameOrID added in v0.6.0

func (actor ActorSummary) UsernameOrID() string

type Attachment

type Attachment struct {
	AttachmentID primitive.ObjectID `bson:"_id"`        // ID of this Attachment
	ObjectID     primitive.ObjectID `bson:"objectId"`   // ID of the Stream that owns this Attachment
	ObjectType   string             `bson:"objectType"` // Type of object that owns this Attachment
	Original     string             `bson:"original"`   // Original filename uploaded by user
	URL          string             `bson:"url"`        // URL where the file is stored
	Rank         int                `bson:"rank"`       // The sort order to display the attachments in.
	Height       int                `bson:"height"`     // Image height (if applicable)
	Width        int                `bson:"width"`      // Image width (if applicable)

	journal.Journal `json:"-" bson:",inline"` // Journal entry for fetch compatability
}

Attachment represents a file that has been uploaded to the software

func NewAttachment

func NewAttachment(objectType string, objectID primitive.ObjectID) Attachment

NewAttachment returns a fully initialized Attachment object.

func (*Attachment) AspectRatio

func (attachment *Attachment) AspectRatio() string

func (*Attachment) CalcURL added in v0.6.0

func (attachment *Attachment) CalcURL(host string) string

func (*Attachment) DownloadExtension

func (attachment *Attachment) DownloadExtension() string

func (*Attachment) DownloadMimeType

func (attachment *Attachment) DownloadMimeType() string

func (*Attachment) GetIntOK

func (attachment *Attachment) GetIntOK(name string) (int, bool)

func (*Attachment) GetStringOK

func (attachment *Attachment) GetStringOK(name string) (string, bool)

func (Attachment) HasDimensions added in v0.6.0

func (attachment Attachment) HasDimensions() bool

func (*Attachment) ID

func (attachment *Attachment) ID() string

ID returns the primary key of this object

func (Attachment) JSONLD added in v0.6.0

func (attachment Attachment) JSONLD() map[string]any

func (*Attachment) MimeCategory

func (attachment *Attachment) MimeCategory() string

func (*Attachment) MimeType

func (attachment *Attachment) MimeType() string

MimeType returns the mime-type of the attached file

func (*Attachment) OriginalExtension

func (attachment *Attachment) OriginalExtension() string

OriginalExtension returns the file extension of the original filename

func (*Attachment) SetInt

func (attachment *Attachment) SetInt(name string, value int) bool

func (*Attachment) SetString

func (attachment *Attachment) SetString(name string, value string) bool

func (*Attachment) SetURL added in v0.6.0

func (attachment *Attachment) SetURL(host string)

type Authorization

type Authorization struct {
	UserID      primitive.ObjectID   `json:"U"`           // Unique identifier of the User
	GroupIDs    []primitive.ObjectID `json:"G"`           // IDs for all server-level groups that the User belongs to
	ClientID    primitive.ObjectID   `json:"C,omitempty"` // Unique identifier of the OAuth Application/Client
	DomainOwner bool                 `json:"O,omitempty"` // If TRUE, then this user is an owner of this domain
	APIUser     bool                 `json:"A,omitempty"` // If TRUE, then this user is an API user
	Scope       string               `json:"S,omitempty"` // OAuth Scopes that this user has access to

	jwt.RegisteredClaims // By embedding the "RegisteredClaims" object, this record can support standard behaviors, like token expiration, etc.
}

Authorization represents the JWT Claims that the server gives to a user when they sign in.

func NewAuthorization

func NewAuthorization() Authorization

NewAuthorization generates a fully initialized Authorization object.

func (*Authorization) AllGroupIDs

func (authorization *Authorization) AllGroupIDs() []primitive.ObjectID

AllGroupIDs returns a slice of groups that this authorization belongs to, including the magic "Anonymous", and (if valid) "Authenticated" groups.

func (Authorization) IsAuthenticated

func (authorization Authorization) IsAuthenticated() bool

IsAuthenticated returns TRUE if this authorization is valid and has a non-zero UserID

func (Authorization) Scopes added in v0.6.0

func (authorization Authorization) Scopes() []string

Scopes returns a slice of scopes that this Authorization token is allowed to use. This implements the toot.ScopesGetter interface.

type Bundle

type Bundle struct {
	ContentType  string `json:"content-type"`
	CacheControl string `json:"cache-control"`
	Content      []byte `json:"-"`
}

Bundle represents a collection of files that are packaged into a Theme, Template, or Widget and are served as a single unit. Recognized content types are automatically minified via github.com/tdewolff/minify/v2.

func (Bundle) GetCacheControl

func (bundle Bundle) GetCacheControl() string

GetCacheControl returns the Cache-Control header for this bundle. If no Cache-Control header is defined, this method returns "public, max-age=3600"

type Client

type Client struct {
	ProviderID string        `bson:"provider"` // ID of the provider that this credential accesses
	Data       mapof.Any     `bson:"data"`     // Unique data for this credential
	Token      *oauth2.Token `bson:"token"`    // OAuth2 Token (if necessary)
	Active     bool          `bson:"active"`   // Is this credential active?
}

Client represents a single connection to an individual Provider. It usually contains an OAuth2 token, but may also contain other connection information like a username or password. It may also represent a connection that is still being formed, for instance, storing the intermediate state of an OAuth2 connection that has not yet completed the three-legged handshake.

func NewClient

func NewClient(providerID string) Client

NewClient returns a fully initialized Client object.

func (Client) GetPointer added in v0.6.0

func (client Client) GetPointer(name string) (any, bool)

func (Client) ID

func (client Client) ID() string

ID implements the set.Value interface

type Content

type Content struct {
	Format string `json:"format" bson:"format"`
	Raw    string `json:"raw"    bson:"raw"`
	HTML   string `json:"html"   bson:"html"`
}

Content represents the WYSIWYG body content in a Stream or Activity

func NewContent added in v0.6.0

func NewContent() Content

func NewHTMLContent

func NewHTMLContent(value string) Content

NewHTMLContent creates a new HTML Content object with the specified HTML value

func NewTextContent

func NewTextContent(value string) Content

NewTextContent creates a new Text Content object with the specified Plaintext value

func (*Content) GetPointer added in v0.6.0

func (content *Content) GetPointer(name string) (any, bool)
type DocumentLink struct {
	ID           primitive.ObjectID `json:"id,omitempty"            bson:"id,omitempty"`           // Internal ID of the record that is being linked
	URL          string             `json:"url,omitempty"           bson:"url,omitempty"`          // URL of the original document
	Label        string             `json:"label,omitempty"         bson:"label,omitempty"`        // Label/Title of the document
	Summary      string             `json:"summary,omitempty"       bson:"summary,omitempty"`      // Brief summary of the document
	ImageURL     string             `json:"imageUrl,omitempty"      bson:"imageUrl,omitempty"`     // URL of the cover image for this document's image
	AttributedTo PersonLink         `json:"attributedTo,omitempty"  bson:"attributedTo,omitempty"` // Person that this document is attributed to
}
func NewDocumentLink() DocumentLink

func (*DocumentLink) GetPointer added in v0.6.0

func (doc *DocumentLink) GetPointer(name string) (any, bool)

func (*DocumentLink) GetStringOK

func (doc *DocumentLink) GetStringOK(name string) (string, bool)

func (*DocumentLink) IsComplete

func (doc *DocumentLink) IsComplete() bool

func (DocumentLink) IsEmpty

func (doc DocumentLink) IsEmpty() bool

IsEmpty returns TRUE if this record does not link to an internal or external document (if both the InternalID and the URL are empty)

func (*DocumentLink) SetString

func (doc *DocumentLink) SetString(name string, value string) bool

type Domain

type Domain struct {
	DomainID        primitive.ObjectID `bson:"_id"`             // This is the internal ID for the domain.  It should not be available via the web service.
	Label           string             `bson:"label"`           // Human-friendly name displayed at the top of this domain
	Description     string             `bson:"description"`     // Human-friendly description of this domain
	ThemeID         string             `bson:"themeId"`         // ID of the theme to use for this domain
	Forward         string             `bson:"forward"`         // If present, then all requests for this domain should be forwarded to the designated new domain.
	Clients         set.Map[Client]    `bson:"clients"`         // External connections (e.g. Facebook, Twitter, etc.)
	ThemeData       mapof.Any          `bson:"themeData"`       // Custom data stored in this domain
	SignupForm      SignupForm         `bson:"signupForm"`      // Valid signup forms to make new accounts.
	DatabaseVersion uint               `bson:"databaseVersion"` // Version of the database schema
	journal.Journal `json:"-" bson:",inline"`
}

Domain represents an account or node on this server.

func NewDomain

func NewDomain() Domain

NewDomain returns a fully initialized Domain object

func (*Domain) GetClient

func (domain *Domain) GetClient(providerID string) (Client, bool)

GetClient returns a client matching the given providerID. The OK return is TRUE if the client has already been configured.

func (*Domain) GetPointer added in v0.6.0

func (domain *Domain) GetPointer(name string) (any, bool)

func (Domain) GetStringOK

func (domain Domain) GetStringOK(name string) (string, bool)

func (*Domain) HasSignupForm

func (domain *Domain) HasSignupForm() bool

HasSignupForm returns TRUE if this domain includes a valid signup form.

func (*Domain) ID

func (domain *Domain) ID() string

ID returns the primary key of this object

func (*Domain) InitClients

func (domain *Domain) InitClients()

func (Domain) IsEmpty added in v0.6.0

func (domain Domain) IsEmpty() bool

func (Domain) NotEmpty added in v0.6.0

func (domain Domain) NotEmpty() bool

func (*Domain) SetClient

func (domain *Domain) SetClient(client Client)

func (*Domain) SetString

func (domain *Domain) SetString(name string, value string) bool

type EncryptionKey

type EncryptionKey struct {
	EncryptionKeyID primitive.ObjectID `json:"encryptionKeyId" bson:"_id"`
	ParentType      string             `json:"parentType"      bson:"parentType"`
	ParentID        primitive.ObjectID `json:"parentId"        bson:"parentId"`
	Encoding        string             `json:"encoding"        bson:"encoding"`
	PublicPEM       string             `json:"publicPEM"       bson:"publicPEM"`
	PrivatePEM      string             `json:"privatePEM"      bson:"privatePEM"`

	journal.Journal `json:"-" bson:",inline"`
}

func NewEncryptionKey

func NewEncryptionKey() EncryptionKey

func (*EncryptionKey) ID

func (encryptionKey *EncryptionKey) ID() string

type FieldLister

type FieldLister interface {
	// FieldList returns the subset of fields that should be queried from the database to
	// populate this object type
	Fields() []string
}

FieldLister wraps the Files() method, which provides the list of fields to query from a database

type Folder

type Folder struct {
	FolderID    primitive.ObjectID `json:"folderId"    bson:"_id"`         // Unique ID for this folder
	UserID      primitive.ObjectID `json:"userId"      bson:"userId"`      // ID of the User who owns this folder
	Label       string             `json:"label"       bson:"label"`       // Label of the folder
	Icon        string             `json:"icon"        bson:"icon"`        // Icon of the folder
	Layout      string             `json:"layout"      bson:"layout"`      // Layout type of the folder
	Group       int                `json:"group"       bson:"group"`       // Group number of the folder (starting with 1)
	Rank        int                `json:"rank"        bson:"rank"`        // Sort order of the folder
	UnreadCount int                `json:"unreadCount" bson:"unreadCount"` // Number of unread messages in this folder

	journal.Journal `json:"-" bson:",inline"`
}

Folder represents a custom folder that organizes incoming messages

func NewFolder

func NewFolder() Folder

NewFolder returns a fully initialized Folder object

func (*Folder) GetIntOK

func (folder *Folder) GetIntOK(name string) (int, bool)

func (Folder) GetRank added in v0.6.0

func (folder Folder) GetRank() int64

func (*Folder) GetStringOK

func (folder *Folder) GetStringOK(name string) (string, bool)

func (Folder) ID

func (folder Folder) ID() string

func (Folder) LookupCode

func (folder Folder) LookupCode() form.LookupCode

func (Folder) Roles

func (folder Folder) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization. Since Folders should only be accessible by the folder owner, this function only returns MagicRoleMyself if applicable. Others (like Anonymous and Authenticated) should never be allowed on an inbox folder, so they are not returned.

func (*Folder) SetInt

func (folder *Folder) SetInt(name string, value int) bool

func (*Folder) SetString

func (folder *Folder) SetString(name string, value string) bool

func (Folder) State

func (folder Folder) State() string

State returns the current state of this object. For users, there is no state, so it returns ""

func (Folder) Toot added in v0.6.0

func (folder Folder) Toot() object.List

type FolderList

type FolderList struct {
	Folders    []Folder `json:"folders"`
	SelectedID primitive.ObjectID
}

FolderList contains a group of folders and the currently selected folder

func NewFolderList

func NewFolderList() FolderList

NewFolderList returns a fully initialized FolderList object

func (FolderList) ByID

func (list FolderList) ByID(folderID primitive.ObjectID) Folder

ByID scans the list for the folder with the specified ID

func (FolderList) HasSelection

func (list FolderList) HasSelection() bool

HasSelection returns TRUE if a folder is currently selected

func (FolderList) Selected

func (list FolderList) Selected() Folder

Selected returns the currently selected folder

type Follower

type Follower struct {
	FollowerID primitive.ObjectID `json:"followerId" bson:"_id"`        // Unique identifier for this Follower
	ParentID   primitive.ObjectID `json:"parentId"   bson:"parentId"`   // Unique identifier for the Stream that is being followed (including user's outboxes)
	Type       string             `json:"type"       bson:"type"`       // Type of record being followed (e.g. "User", "Stream")
	Method     string             `json:"method"     bson:"method"`     // Method of follower (e.g. "POLL", "WEBSUB", "RSS-CLOUD", "ACTIVITYPUB")
	Format     string             `json:"format"     bson:"format"`     // Format of the data being followed (e.g. "JSON", "XML", "ATOM", "RSS")
	Actor      PersonLink         `json:"actor"      bson:"actor"`      // Person who is follower the User
	Data       mapof.Any          `json:"data"       bson:"data"`       // Additional data about this Follower that depends on the follow method
	ExpireDate int64              `json:"expireDate" bson:"expireDate"` // Unix timestamp (in seconds) when this follower will be automatically purged.

	journal.Journal `json:"-" bson:",inline"`
}

func NewFollower

func NewFollower() Follower

func (Follower) GetJSONLD added in v0.6.0

func (follower Follower) GetJSONLD() mapof.Any

func (*Follower) GetPointer added in v0.6.0

func (follower *Follower) GetPointer(name string) (any, bool)

func (*Follower) GetStringOK

func (follower *Follower) GetStringOK(name string) (string, bool)

func (*Follower) ID

func (follower *Follower) ID() string

func (Follower) Roles

func (follower Follower) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization. Since Follower records should only be accessible by the follower owner, this function only returns MagicRoleMyself if applicable. Others (like Anonymous and Authenticated) should never be allowed on an Follower record, so they are not returned.

func (*Follower) SetString

func (follower *Follower) SetString(name string, value string) bool

func (Follower) State

func (follower Follower) State() string

State returns the current state of this object. For users, there is no state, so it returns ""

type FollowerSummary

type FollowerSummary struct {
	FollowerID primitive.ObjectID `json:"summaryId" bson:"_id"`      // Unique identifier for this Follower
	ParentID   primitive.ObjectID `json:"parentId"  bson:"parentId"` // Unique identifier for the User that is being followed
	Actor      PersonLink         `json:"actor"     bson:"actor"`    // Person who is follower the User
	Method     string             `json:"method"    bson:"method"`   // Method of follower (e.g. "RSS", "RSSCloud", "ActivityPub".)
}

func (FollowerSummary) Fields

func (summary FollowerSummary) Fields() []string

func (FollowerSummary) MethodIcon

func (summary FollowerSummary) MethodIcon() string

type Following

type Following struct {
	FollowingID     primitive.ObjectID `json:"followingId"     bson:"_id"`             // Unique Identifier of this record
	UserID          primitive.ObjectID `json:"userId"          bson:"userId"`          // ID of the stream that owns this "following"
	FolderID        primitive.ObjectID `json:"folderId"        bson:"folderId"`        // ID of the folder to put new messages into
	Folder          string             `json:"folder"          bson:"folder"`          // Name of the folder to put new messages into
	Label           string             `json:"label"           bson:"label"`           // Label of this "following" record
	Notes           string             `json:"notes"         bson:"notes"`             // Notes about this "following" record, entered by the user.
	URL             string             `json:"url"             bson:"url"`             // Human-Facing URL that is being followed.
	ProfileURL      string             `json:"profileUrl"      bson:"profileUrl"`      // Updated, computer-facing URL that is being followed.
	ImageURL        string             `json:"imageUrl"        bson:"imageUrl"`        // URL of an image that represents this "following"
	Behavior        string             `json:"behavior"        bson:"behavior"`        // Behavior determines the types of records to import from this Actor [POSTS+REPLIES]
	RuleAction      string             `json:"ruleAction"      bson:"ruleAction"`      // RuleAction determines the types of records to rule from this Actor [IGNORE, LABEL, MUTE, BLOCK ]
	CollapseThreads bool               `json:"collapseThreads" bson:"collapseThreads"` // If TRUE, traverse responses and import the initial post that initiated a thread
	IsPublic        bool               `json:"isPublic"        bson:"isPublic"`        // If TRUE, this following is visible to the public
	Links           digit.LinkSet      `json:"links"           bson:"links"`           // List of links can be used to update this following.
	Method          string             `json:"method"          bson:"method"`          // Method used to update this feed (POLL, WEBSUB, RSS-CLOUD, ACTIVITYPUB)
	Secret          string             `json:"secret"          bson:"secret"`          // Secret used to authenticate this feed (if required)
	Status          string             `json:"status"          bson:"status"`          // Status of the last poll of Following (NEW, CONNECTING, POLLING, SUCCESS, FAILURE)
	StatusMessage   string             `json:"statusMessage"   bson:"statusMessage"`   // Optional message describing the status of the last poll
	LastPolled      int64              `json:"lastPolled"      bson:"lastPolled"`      // Unix Timestamp of the last date that this resource was retrieved.
	PollDuration    int                `json:"pollDuration"    bson:"pollDuration"`    // Time (in hours) to wait between polling this resource.
	NextPoll        int64              `json:"nextPoll"        bson:"nextPoll"`        // Unix Timestamp of the next time that this resource should be polled.
	PurgeDuration   int                `json:"purgeDuration"   bson:"purgeDuration"`   // Time (in days) to wait before purging old messages
	ErrorCount      int                `json:"errorCount"      bson:"errorCount"`      // Number of times that this "following" has failed to load (for exponential backoff)

	journal.Journal `json:"-" bson:",inline"`
}

Following is a model object that represents a user's following to an external data feed. Currently, the only supported feed types are: RSS, Atom, and JSON Feed. Others may be added in the future.

func NewFollowing

func NewFollowing() Following

NewFollowing returns a fully initialized Following object

func (following *Following) GetLink(property string, value string) digit.Link

GetLink returns a link from the Following that matches the given property and value

func (*Following) GetPointer added in v0.6.0

func (following *Following) GetPointer(name string) (any, bool)

func (Following) GetStringOK

func (following Following) GetStringOK(name string) (string, bool)

func (Following) ID

func (following Following) ID() string

ID returns the primary key of this object

func (Following) IsZero

func (following Following) IsZero() bool

func (Following) NotZero added in v0.6.0

func (following Following) NotZero() bool

func (*Following) Origin

func (following *Following) Origin(originType string) OriginLink

func (Following) Roles

func (following Following) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization. Since Following records should only be accessible by the following owner, this function only returns MagicRoleMyself if applicable. Others (like Anonymous and Authenticated) should never be allowed on an Following record, so they are not returned.

func (following *Following) SetLinks(newLinks ...digit.Link)

SetLinks adds or replaces a link in the Following that matches the given property

func (*Following) SetString

func (following *Following) SetString(name string, value string) bool

func (Following) State

func (following Following) State() string

State returns the current state of this object. For users, there is no state, so it returns ""

func (Following) Toot added in v0.6.0

func (following Following) Toot() object.Relationship

type FollowingSummary

type FollowingSummary struct {
	FollowingID primitive.ObjectID `bson:"_id"`
	URL         string             `bson:"url"`
	Label       string             `bson:"label"`
	Folder      string             `bson:"folder"`
	FolderID    primitive.ObjectID `bson:"folderId"`
	ImageURL    string             `bson:"imageUrl"`
	Method      string             `bson:"method"`
	Status      string             `bson:"status"`
	LastPolled  int64              `bson:"lastPolled"`
	NextPoll    int64              `bson:"nextPoll"`
	CreateDate  int64              `bson:"createDate"`
}

func (FollowingSummary) Fields

func (summary FollowingSummary) Fields() []string

func (FollowingSummary) GetRank added in v0.6.0

func (summary FollowingSummary) GetRank() int64

func (FollowingSummary) Icon

func (summary FollowingSummary) Icon() string

func (FollowingSummary) StatusClass

func (summary FollowingSummary) StatusClass() string

type Group

type Group struct {
	GroupID primitive.ObjectID `json:"groupId" bson:"_id"`
	Label   string             `json:"label"   bson:"label"`

	journal.Journal `json:"-" bson:",inline"`
}

func NewGroup

func NewGroup() Group

func (Group) Fields

func (userSummary Group) Fields() []string

func (*Group) GetStringOK

func (group *Group) GetStringOK(name string) (string, bool)

func (*Group) ID

func (group *Group) ID() string

func (*Group) LookupCode

func (group *Group) LookupCode() form.LookupCode

func (*Group) SetString

func (group *Group) SetString(name string, value string) bool

type JSONLDGetter

type JSONLDGetter interface {
	GetJSONLD() mapof.Any
	Created() int64
}

ActivityPubProfileGetter wraps the ActivityPubProfile() method, which lets a model object return its data formatted in JSON-LD

type JWTKey added in v0.6.0

type JWTKey struct {
	JWTKeyID       primitive.ObjectID `bson:"_id"`
	KeyName        string             `bson:"keyName"`
	Algorithm      string             `bson:"algorithm"`
	Plaintext      []byte             `bson:"-"`
	EncryptedValue []byte             `bson:"encryptedValue"`

	journal.Journal `json:"-" bson:",inline"`
}

JWTKey represents

func NewJWTKey added in v0.6.0

func NewJWTKey() JWTKey

func (JWTKey) ID added in v0.6.0

func (key JWTKey) ID() string

type Mention

type Mention struct {
	MentionID primitive.ObjectID `json:"mentionId" bson:"_id"`      // Unique ID for this record
	ObjectID  primitive.ObjectID `json:"objectId"  bson:"objectId"` // Unique ID of the internal object that was mentioned
	Type      string             `json:"type"      bson:"type"`     // Type of object that was mentioned (Stream, User)
	StateID   string             `json:"stateId"   bson:"stateId"`  // State of this mention (Validated, Pending, Invalid)
	Origin    OriginLink         `json:"origin"    bson:"origin"`   // Origin information of the site that mentions this object
	Author    PersonLink         `json:"author"    bson:"author"`   // Author information of the person who mentioned this object

	journal.Journal `json:"-" bson:",inline"`
}

Mention represents a single hyperlink from an external source to an internal object. Mentions are created by WebMentions or by ActivityPub "Mention" records

func NewMention

func NewMention() Mention

NewMention returns a fully initialized Mention object

func (*Mention) GetPointer added in v0.6.0

func (mention *Mention) GetPointer(name string) (any, bool)

func (*Mention) GetStringOK

func (mention *Mention) GetStringOK(name string) (string, bool)

func (Mention) ID

func (mention Mention) ID() string

ID returns a string representation of the Mention's unique id. This method implements the data.Object interface.

func (*Mention) SetString

func (mention *Mention) SetString(name string, value string) bool

type Message

type Message struct {
	MessageID   primitive.ObjectID         `json:"messageId"    bson:"_id"`                   // Unique ID of the Message
	UserID      primitive.ObjectID         `json:"userId"       bson:"userId"`                // Unique ID of the User who owns this Message
	FollowingID primitive.ObjectID         `json:"followingId"  bson:"followingId,omitempty"` // Unique ID of the Following record that generated this Message
	FolderID    primitive.ObjectID         `json:"folderId"     bson:"folderId,omitempty"`    // Unique ID of the Folder where this Message is stored
	SocialRole  string                     `json:"socialRole"   bson:"socialRole,omitempty"`  // Role this message plays in social integrations ("Article", "Note", etc)
	Origin      OriginLink                 `json:"origin"       bson:"origin,omitempty"`      // Link to the original source of this Message (the following and website that originally published it)
	References  sliceof.Object[OriginLink] `json:"references"   bson:"references,omitempty"`  // Links to other references to this Message - likes, reposts, or comments that informed us of its existence
	URL         string                     `json:"url"          bson:"url"`                   // URL of this Message
	InReplyTo   string                     `json:"inReplyTo"    bson:"inReplyTo,omitempty"`   // URL this message is in reply to
	MyResponse  string                     `json:"myResponse"   bson:"myResponse,omitempty"`  // If the owner of this message has responded, then this field contains the responseType (Like, Dislike, Repost)
	StateID     string                     `json:"stateId"      bson:"stateId"`               // StateID of this message (UNREAD,READ,MUTED,NEW-REPLIES)
	ReadDate    int64                      `json:"readDate"     bson:"readDate"`              // Unix timestamp of the date/time when this Message was read.  If unread, this is MaxInt64.
	PublishDate int64                      `json:"publishDate"  bson:"publishDate,omitempty"` // Unix timestamp of the date/time when this Message was published
	Rank        int64                      `json:"rank"         bson:"rank"`                  // Sort rank for this message (publishDate * 1000 + sequence number)

	journal.Journal `json:"-" bson:",inline"`
}

Message represents a single item in a User's inbox or outbox. It is loosely modelled on the MessageStreams standard, and can be converted into a strict go-fed streams.Type object.

func NewMessage

func NewMessage() Message

NewMessage returns a fully initialized Message record

func (*Message) AddReference added in v0.6.0

func (message *Message) AddReference(reference OriginLink) bool

AddReference adds a new reference to this message, while attempting to prevent duplicates. It returns TRUE if the message has been updated.

func (Message) Fields added in v0.6.0

func (summary Message) Fields() []string

func (*Message) GetPointer added in v0.6.0

func (message *Message) GetPointer(name string) (any, bool)

func (Message) GetRank added in v0.6.0

func (message Message) GetRank() int64

func (*Message) GetStringOK

func (message *Message) GetStringOK(name string) (string, bool)

func (Message) ID

func (message Message) ID() string

func (Message) IsRead added in v0.6.0

func (message Message) IsRead() bool

IsRead returns TRUE if this message has a valid ReadDate

func (*Message) MarkMuted added in v0.6.0

func (message *Message) MarkMuted() bool

MarkMuted sets the stateID of this Message to "MUTED" This function returns TRUE if the value was changed

func (*Message) MarkNewReplies added in v0.6.0

func (message *Message) MarkNewReplies() bool

MarkNewReplies sets the stateID of this Message to "NEW-REPLIES" ReadDate is cleared to MaxInt64 This function returns TRUE if the value was changed

func (*Message) MarkRead added in v0.6.0

func (message *Message) MarkRead() bool

MarkRead sets the stateID of this Message to "READ". If the ReadDate is not already set, then it is set to the current time. This function returns TRUE if the value was changed

func (*Message) MarkUnmuted added in v0.6.0

func (message *Message) MarkUnmuted() bool

MarkRead sets the stateID of this Message to "READ". If the ReadDate is not already set, then it is set to the current time. This function returns TRUE if the value was changed

func (*Message) MarkUnread added in v0.6.0

func (message *Message) MarkUnread() bool

MarkUnread sets the stateID of this Message to "UNREAD" ReadDate is cleared to MaxInt64 This function returns TRUE if the value was changed

func (Message) NotRead added in v0.6.0

func (message Message) NotRead() bool

NotRead returns TRUE if this message does not have a valid ReadDate

func (Message) RankSeconds added in v0.6.0

func (message Message) RankSeconds() int64

RankSeconds returns the rank of this Message in seconds (ignoring milliseconds)

func (Message) Roles

func (message Message) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization

func (*Message) SetMyResponse added in v0.6.0

func (message *Message) SetMyResponse(responseType string)

SetMyResponse

func (*Message) SetState added in v0.6.0

func (message *Message) SetState(stateID string)

SetState implements the model.StateSetter interface, and updates the message.StateID by wrapping the MarkXXX() methods. This method is primarily used by HTML templates in the build pipeline. Services and handlers written in Go should probably use MarkRead(), MarkUnread(), etc. directly.

func (*Message) SetString

func (message *Message) SetString(name string, value string) bool

func (Message) State

func (message Message) State() string

State returns the current state of this Stream. It is part of the implementation of the RoleStateEmulator interface

func (Message) Toot added in v0.6.0

func (message Message) Toot() object.Status

Toot returns this object represented as a toot stateID

type OAuthAuthorizationRequest added in v0.6.0

type OAuthAuthorizationRequest struct {
	ResponseType string `query:"response_type" form:"response_type"`
	ClientID     string `query:"client_id"     form:"client_id"`
	RedirectURI  string `query:"redirect_uri"  form:"redirect_uri"`
	Scope        string `query:"scope"         form:"scope"`
	ForceLogin   bool   `query:"force_login"   form:"force_login"`
	Language     string `query:"language"      form:"language"`
}

https://docs.joinmastodon.org/methods/oauth/#authorize GET /oauth/authorize Returns: Authorization code

func NewOAuthAuthorizationRequest added in v0.6.0

func NewOAuthAuthorizationRequest() OAuthAuthorizationRequest

func (OAuthAuthorizationRequest) Scopes added in v0.6.0

func (req OAuthAuthorizationRequest) Scopes() []string

func (*OAuthAuthorizationRequest) Validate added in v0.6.0

func (req *OAuthAuthorizationRequest) Validate(app OAuthClient) error

Validate confirms that a request is valid based on the settings in the OAuthClient. This method MAY update the request if certain values are missing.

type OAuthClient added in v0.6.0

type OAuthClient struct {
	ClientID     primitive.ObjectID `json:"clientId"      bson:"_id"`
	ClientSecret string             `json:"clientSecret"  bson:"clientSecret"`
	Name         string             `json:"name"          bson:"name"`
	Website      string             `json:"website"       bson:"website"`
	RedirectURIs []string           `json:"redirectUris"  bson:"redirectUris"`
	Scopes       sliceof.String     `json:"scopes"        bson:"scopes"`

	journal.Journal `json:"-" bson:",inline"`
}

func NewOAuthClient added in v0.6.0

func NewOAuthClient() OAuthClient

func (*OAuthClient) GetPointer added in v0.6.0

func (app *OAuthClient) GetPointer(name string) (any, bool)

func (*OAuthClient) GetStringOK added in v0.6.0

func (app *OAuthClient) GetStringOK(name string) (string, bool)

func (OAuthClient) ID added in v0.6.0

func (app OAuthClient) ID() string

func (*OAuthClient) SetString added in v0.6.0

func (app *OAuthClient) SetString(name string, value string) bool

func (OAuthClient) Toot added in v0.6.0

func (app OAuthClient) Toot() object.Application

ToToot converts this object into a Mastodon-compatible Application object

type OAuthUserToken added in v0.6.0

type OAuthUserToken struct {
	OAuthUserTokenID primitive.ObjectID `json:"-" bson:"_id"`
	ClientID         primitive.ObjectID `json:"C" bson:"clientId"`
	UserID           primitive.ObjectID `json:"U" bson:"userId"`
	Token            string             `json:"T" bson:"token"`
	APIUser          bool               `json:"A" bson:"apiUser"`
	Scopes           sliceof.String     `json:"S" bson:"scopes"`

	journal.Journal `json:"-" bson:",inline"`
}

UserOAuthToken represents an application-specific token that a remote API can use to access a user's account on their behalf

func NewOAuthUserToken added in v0.6.0

func NewOAuthUserToken() OAuthUserToken

func (OAuthUserToken) Code added in v0.6.0

func (token OAuthUserToken) Code() string

Code returns the OAuth2 code that is used to request an access token. This is just the string version of the ID.

func (*OAuthUserToken) GetPointer added in v0.6.0

func (userToken *OAuthUserToken) GetPointer(name string) (any, bool)

func (*OAuthUserToken) GetStringOK added in v0.6.0

func (userToken *OAuthUserToken) GetStringOK(name string) (string, bool)

func (OAuthUserToken) ID added in v0.6.0

func (token OAuthUserToken) ID() string

func (OAuthUserToken) JSONResponse added in v0.6.0

func (token OAuthUserToken) JSONResponse() map[string]any

func (*OAuthUserToken) SetString added in v0.6.0

func (userToken *OAuthUserToken) SetString(name string, value string) bool

func (OAuthUserToken) Toot added in v0.6.0

func (token OAuthUserToken) Toot() object.Token

type OAuthUserTokenRequest added in v0.6.0

type OAuthUserTokenRequest struct {
	GrantType    string `form:"grant_type"`
	Code         string `form:"code"`
	ClientID     string `form:"client_id"`
	ClientSecret string `form:"client_secret"`
	RedirectURI  string `form:"redirect_uri"`
	Scope        string `form:"scope"`
}

https://docs.joinmastodon.org/methods/oauth/#token POST /oauth/token Returns: Token Obtain an access token, to be used during API calls that are not public

func NewOAuthUserTokenRequest added in v0.6.0

func NewOAuthUserTokenRequest() OAuthUserTokenRequest

func (OAuthUserTokenRequest) Scopes added in v0.6.0

func (o OAuthUserTokenRequest) Scopes() []string

func (*OAuthUserTokenRequest) Validate added in v0.6.0

func (req *OAuthUserTokenRequest) Validate(app OAuthClient) error

Validate confirms that a request is valid based on the settings in the OAuthClient. This method MAY update the request if certain values are missing.

type OAuthUserTokenRevokeRequest added in v0.6.0

type OAuthUserTokenRevokeRequest struct {
	ClientID     string `form:"client_id"`
	ClientSecret string `form:"client_secret"`
	Token        string `form:"token"`
}

https://docs.joinmastodon.org/methods/oauth/#revoke POST /oauth/revoke Returns: Empty struct Revoke an access token to make it no longer valid for use

func NewOAuthUserTokenRevokeRequest added in v0.6.0

func NewOAuthUserTokenRevokeRequest() OAuthUserTokenRevokeRequest

func (*OAuthUserTokenRevokeRequest) Validate added in v0.6.0

func (req *OAuthUserTokenRevokeRequest) Validate(app OAuthClient) error
type OriginLink struct {
	Type        string             `json:"type"        bson:"type,omitempty"`        // The type of message that this document (DIRECT, LIKE, DISLIKE, REPLY, ANNOUNCE)
	FollowingID primitive.ObjectID `json:"followingId" bson:"followingId,omitempty"` // Unique ID of a document in this database
	Label       string             `json:"label"       bson:"label,omitempty"`       // Human-friendly label of the origin
	URL         string             `json:"url"         bson:"url,omitempty"`         // Public URL of the origin
	ImageURL    string             `json:"imageUrl"    bson:"imageUrl,omitempty"`    // URL of the cover image for this document's image
}

OriginLink represents the original source of a stream that has been imported into Emissary. This could be an external ActivityPub server, RSS Feed, or Tweet.

func NewOriginLink() OriginLink

NewOriginLink returns a fully initialized OriginLink

func (OriginLink) Equals added in v0.6.0

func (origin OriginLink) Equals(other OriginLink) bool

Equals returns TRUE if the URL for this OriginLink is the same as the URL for another OriginLink

func (*OriginLink) GetPointer added in v0.6.0

func (origin *OriginLink) GetPointer(name string) (any, bool)

func (*OriginLink) GetStringOK

func (origin *OriginLink) GetStringOK(name string) (string, bool)

func (OriginLink) Icon

func (origin OriginLink) Icon() string

Icon returns the standard icon label for this origin

func (OriginLink) IsEmpty

func (origin OriginLink) IsEmpty() bool

IsEmpty returns TRUE if this OriginLink is empty

func (OriginLink) NotEmpty added in v0.6.0

func (origin OriginLink) NotEmpty() bool

func (*OriginLink) SetString

func (origin *OriginLink) SetString(name string, value string) bool

type OutboxMessage added in v0.6.0

type OutboxMessage struct {
	OutboxMessageID primitive.ObjectID `json:"messageId"  bson:"_id"`        // Unique ID of the OutboxMessage
	ParentType      string             `json:"parentType" bson:"parentType"` // Type of the parent object (User or Stream)
	ParentID        primitive.ObjectID `json:"parentId"   bson:"parentId"`   // Unique ID of the User who owns this OutboxMessage (in their inbox or outbox)
	ActivityType    string             `json:"type"       bson:"type"`       // Type of the activity (Create, Follow, Like, Block, etc.)
	URL             string             `json:"url"        bson:"url"`        // URL of the object (if applicable)

	journal.Journal `json:"-" bson:",inline"`
}

OutboxMessage represents a single item in a User's inbox or outbox. It is loosely modelled on the OutboxMessageStreams standard, and can be converted into a strict go-fed streams.Type object.

func NewOutboxMessage added in v0.6.0

func NewOutboxMessage() OutboxMessage

NewOutboxMessage returns a fully initialized OutboxMessage record

func (OutboxMessage) Fields added in v0.6.0

func (summary OutboxMessage) Fields() []string

func (OutboxMessage) ID added in v0.6.0

func (message OutboxMessage) ID() string

type OutboxMessageSummary added in v0.6.0

type OutboxMessageSummary struct {
	URL        string `bson:"url"`
	CreateDate int64  `bson:"createDate"`
}

func NewOutboxMessageSummary added in v0.6.0

func NewOutboxMessageSummary() OutboxMessageSummary

func (OutboxMessageSummary) Created added in v0.6.0

func (message OutboxMessageSummary) Created() int64

func (OutboxMessageSummary) GetJSONLD added in v0.6.0

func (message OutboxMessageSummary) GetJSONLD() mapof.Any

type PasswordReset

type PasswordReset struct {
	AuthCode   string
	CreateDate int64 `json:"createDate"`
	ExpireDate int64 `json:"expireDate"`
}

PasswordReset represents a single password reset request. Only one password reset request is allowed per user.

func NewPasswordReset

func NewPasswordReset(duration time.Duration) PasswordReset

func (PasswordReset) IsExpired

func (reset PasswordReset) IsExpired() bool

IsExpired returns TRUE if the password reset has expired

func (PasswordReset) IsValid

func (reset PasswordReset) IsValid(code string) bool

IsValid returns TRUE if the password reset code is valid and has not expired.

type PersonLink struct {
	UserID       primitive.ObjectID `json:"userId,omitempty"       bson:"userId,omitempty"`       // Internal ID of the person (if they exist in this database)
	Name         string             `json:"name,omitempty"         bson:"name,omitempty"`         // Name of the person
	ProfileURL   string             `json:"profileUrl,omitempty"   bson:"profileUrl,omitempty"`   // URL of the person's profile
	InboxURL     string             `json:"inboxUrl,omitempty"     bson:"inboxUrl,omitempty"`     // URL of the person's inbox
	EmailAddress string             `json:"emailAddress,omitempty" bson:"emailAddress,omitempty"` // Email address of the person
	ImageURL     string             `json:"imageUrl,omitempty"     bson:"imageUrl,omitempty"`     // URL of the person's avatar image
}
func NewPersonLink() PersonLink

func (PersonLink) GetJSONLD added in v0.6.0

func (person PersonLink) GetJSONLD() mapof.Any

func (*PersonLink) GetPointer added in v0.6.0

func (link *PersonLink) GetPointer(name string) (any, bool)

func (*PersonLink) GetStringOK

func (link *PersonLink) GetStringOK(name string) (string, bool)

func (PersonLink) GetURL

func (person PersonLink) GetURL(name string) *url.URL

GetURL gets a named property value of this person, then retuns it as a parsed URL. Only "profileUrl" "inboxUrl" and "imageUrl" should be passed to this function. all others will return nil values

func (PersonLink) HasImageURL added in v0.6.0

func (person PersonLink) HasImageURL() bool

func (PersonLink) IsEmpty

func (person PersonLink) IsEmpty() bool

IsEmpty returns TRUE if this record does not link to an internal or external person (if the UserID, ProfileURL, and Name are all empty)

func (PersonLink) NotEmpty added in v0.6.0

func (person PersonLink) NotEmpty() bool

func (*PersonLink) SetString

func (link *PersonLink) SetString(name string, value string) bool

func (PersonLink) Toot added in v0.6.0

func (person PersonLink) Toot() object.Account

type Response added in v0.6.0

type Response struct {
	ResponseID primitive.ObjectID `json:"responseId" bson:"_id"`               // Unique identifier for this Response
	UserID     primitive.ObjectID `json:"userId"     bson:"userId"`            // ID of the User who made this response
	Actor      string             `json:"actor"      bson:"actor"`             // ActivityPubURL of the User who made the response
	Object     string             `json:"object"     bson:"object"`            // ActivityPubURL of the Object that the actor responded to
	Type       string             `json:"type"       bson:"type"`              // Type of Response (e.g. "Announce", "Bookmark", "Like", "Dislike", etc...)
	Summary    string             `json:"summary"    bson:"summary,omitempty"` // Summary of the response (e.g. "I liked this post because...")
	Content    string             `json:"content"    bson:"content,omitempty"` // Custom value assigned to the response (emoji, vote, etc.)

	journal.Journal `json:"-" bson:",inline"`
}

Reponse defines a single Actor's response to an Object. The actor may be a local or remote user, and the Object may be a local stream or an inbox message.

func NewResponse added in v0.6.0

func NewResponse() Response

NewReponse returns a fully initialized Response object

func (Response) ActivityPubCreateDate added in v0.6.0

func (response Response) ActivityPubCreateDate() string

func (Response) ActivityPubURL added in v0.6.0

func (response Response) ActivityPubURL() string

func (Response) CreateDateSeconds added in v0.6.0

func (response Response) CreateDateSeconds() int64

CreateDateSeconds returns the CreateDate in Unix Epoch seconds (instead of milliseconds)

func (Response) Fields added in v0.6.0

func (response Response) Fields() []string

func (Response) GetJSONLD added in v0.6.0

func (response Response) GetJSONLD() mapof.Any

GetJSONLD returns the JSON-LD representation of this Response

func (*Response) GetPointer added in v0.6.0

func (response *Response) GetPointer(name string) (any, bool)

func (Response) GetStringOK added in v0.6.0

func (response Response) GetStringOK(name string) (string, bool)

func (Response) ID added in v0.6.0

func (response Response) ID() string

ID returns the unique identifier for this Response (in string format)

func (Response) IsEmpty added in v0.6.0

func (response Response) IsEmpty() bool

IsEmpty returns TRUE if this Response has no data in it.

func (Response) IsEqual added in v0.6.0

func (response Response) IsEqual(other Response) bool

IsEqual returns TRUE if two responses match urls, actors, objects, types, and values

func (Response) NotEmpty added in v0.6.0

func (response Response) NotEmpty() bool

NotEmpty returns TRUE if this Response has data in it.

func (Response) Roles added in v0.6.0

func (response Response) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization

func (*Response) SetString added in v0.6.0

func (response *Response) SetString(name string, value string) bool

func (Response) State added in v0.6.0

func (response Response) State() string

State returns the current state of this Stream. It is part of the implementation of the RoleStateEmulator interface

func (Response) Toot added in v0.6.0

func (response Response) Toot() object.Status

type Role

type Role struct {
	RoleID      string `json:"roleId"      bson:"roleId"`      // Unique ID for this role
	Label       string `json:"label"       bson:"label"`       // Short, human-friendly label used to select this role in UX
	Description string `json:"description" bson:"description"` // Medium-length, human-friendly description that gives more details about this role
}

Role is used in a map[sring]Role within each Template. Role IDs are used to identify what actions a User can take on a Stream (given the user's Groups and the Stream's Template)

type RoleStateEnumerator

type RoleStateEnumerator interface {

	// State returns the current state of the object.
	State() string

	// Roles Returns the list of roles granted by the provided authorization
	Roles(*Authorization) []string
}

RoleStateEnumerator wraps the methods required for an object to declare what authorized roles/state combinations are required for access.

type Rule added in v0.6.0

type Rule struct {
	RuleID         primitive.ObjectID `json:"ruleId"         bson:"_id"`            // Unique identifier of this Rule
	UserID         primitive.ObjectID `json:"userId"         bson:"userId"`         // Unique identifier of the User who owns this Rule
	FollowingID    primitive.ObjectID `json:"followingId"    bson:"followingId"`    // Unique identifier of the Following record that created this Rule.  If Zero, then this rule was created by the user.
	FollowingLabel string             `json:"followingLabel" bson:"followingLabel"` // Label of the Following record that created this Rule.
	Type           string             `json:"type"           bson:"type"`           // Type of Rule (e.g. "ACTOR", "DOMAIN", "CONTENT")
	Action         string             `json:"action"         bson:"action"`         // Action to take when this rule is triggered (e.g. "BLOCK", "MUTE", "LABEL")
	Label          string             `json:"label"          bson:"label"`          // Human-friendly label to add to messages
	Trigger        string             `json:"trigger"        bson:"trigger"`        // Parameter for this rule type)
	Summary        string             `json:"summary"        bson:"summary"`        // Optional comment describing why this rule exists
	IsPublic       bool               `json:"isPublic"       bson:"isPublic"`       // If TRUE, this record is visible publicly
	PublishDate    int64              `json:"publishDate"    bson:"publishDate"`    // Unix timestamp when this rule was published to followers

	journal.Journal `json:"-" bson:",inline"`
}

Rule represents many kinds of filters that are applied to messages before they are added into a User's inbox

func NewRule added in v0.6.0

func NewRule() Rule

func (Rule) Fields added in v0.6.0

func (rule Rule) Fields() []string

func (Rule) FilterByActor added in v0.6.0

func (rule Rule) FilterByActor(actor string) bool

FilterByActor returns TRUE if the provided actor should be ruleed

func (Rule) FilterByActorAndContent added in v0.6.0

func (rule Rule) FilterByActorAndContent(actor string, content ...string) bool

func (Rule) FilterByActors added in v0.6.0

func (rule Rule) FilterByActors(actors ...string) bool

func (Rule) FilterByContent added in v0.6.0

func (rule Rule) FilterByContent(content string) bool

func (*Rule) GetPointer added in v0.6.0

func (rule *Rule) GetPointer(name string) (any, bool)

func (Rule) GetRank added in v0.6.0

func (rule Rule) GetRank() int64

GetRank returns the "Rank" of this object, which is its CreateDate

func (*Rule) GetStringOK added in v0.6.0

func (rule *Rule) GetStringOK(name string) (string, bool)

func (Rule) ID added in v0.6.0

func (rule Rule) ID() string

func (Rule) Origin added in v0.6.0

func (rule Rule) Origin() string

Origin returns a string that identifies the origin of this Rule. (DOMAIN, REMOTE, or USER)

func (Rule) OriginAdmin added in v0.6.0

func (rule Rule) OriginAdmin() bool

OriginAdmin returns TRUE if this Rule was created by a Domain administrator.

func (Rule) OriginRemote added in v0.6.0

func (rule Rule) OriginRemote() bool

OriginRemote returns TRUE if this Rule was created by a Following record.

func (Rule) OriginUser added in v0.6.0

func (rule Rule) OriginUser() bool

OriginUser returns TRUE if this Rule was created by the User.

func (Rule) Roles added in v0.6.0

func (rule Rule) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization. Since Rule records should only be accessible by the rule owner, this function only returns MagicRoleMyself if applicable. Others (like Anonymous and Authenticated) should never be allowed on an Rule record, so they are not returned.

func (*Rule) SetString added in v0.6.0

func (rule *Rule) SetString(name string, value string) bool

func (Rule) State added in v0.6.0

func (rule Rule) State() string

State returns the current state of this object. For users, there is no state, so it returns ""

func (Rule) Toot added in v0.6.0

func (rule Rule) Toot() object.Relationship

type RuleSummary added in v0.6.0

type RuleSummary struct {
	RuleID         primitive.ObjectID `bson:"_id"`
	Type           string             `bson:"type"`
	Action         string             `bson:"action"`
	Behavior       string             `bson:"behavior"`
	Trigger        string             `bson:"trigger"`
	Label          string             `bson:"label"`
	FollowingLabel string             `bson:"followingLabel"`
}

RuleSummary is a trimmed down subset of the Rule object, which is used when executing rules on a piece of content

func (RuleSummary) Fields added in v0.6.0

func (rule RuleSummary) Fields() []string

func (RuleSummary) IsAllowed added in v0.6.0

func (rule RuleSummary) IsAllowed(document *streams.Document) bool

IsAllowed returns TRUE if the document should be allowed based on this rule. (i.e. the document DOES NOT match the rule)

func (RuleSummary) IsDisallowSend added in v0.6.0

func (rule RuleSummary) IsDisallowSend(recipient string) bool

func (RuleSummary) IsDisallowed added in v0.6.0

func (rule RuleSummary) IsDisallowed(document *streams.Document) bool

IsDisallowed returns TRUE if the document SHOULD NOT BE allowed based on this rule. (i.e. the document MATCHES the rule)

type SignupForm

type SignupForm struct {
	Title   string             `json:"title"   bson:"title"`   // Title displayed on the signup page
	Message string             `json:"message" bson:"message"` // Message displayed on the signup page
	GroupID primitive.ObjectID `json:"groupId" bson:"groupId"` // Group to add new users to when completed
	Active  bool               `json:"active"  bson:"active"`  // If true, then allow this signup page
}

func NewSignupForm

func NewSignupForm() SignupForm

func (SignupForm) GetBoolOK

func (form SignupForm) GetBoolOK(name string) (bool, bool)

func (SignupForm) GetStringOK

func (form SignupForm) GetStringOK(name string) (string, bool)

func (*SignupForm) SetBool

func (form *SignupForm) SetBool(name string, value bool) bool

func (*SignupForm) SetString

func (form *SignupForm) SetString(name string, value string) bool

type State

type State struct {
	StateID     string `json:"stateId"     bson:"stateId"`     // Unique ID for this state (within this Template)
	Label       string `json:"label"       bson:"label"`       // Human-friendly label for this State
	Description string `json:"description" bson:"description"` // Description of this State
}

State defines an individual state that a Template/Stream can be in. States are the basis for transitions, forms, and actions.

func NewState

func NewState() State

NewState returns a fully initialized State object.

type StateSetter added in v0.6.0

type StateSetter interface {
	// SetState updates the state of the object. The meaning of
	// this behavior is defined by the object.
	SetState(string)
}

StateSetter wraps the SetState() method, which updates the state of an object.

type Stream

type Stream struct {
	StreamID         primitive.ObjectID           `json:"streamId"               bson:"_id"`                    // Unique identifier of this Stream.
	ParentID         primitive.ObjectID           `json:"parentId"               bson:"parentId"`               // Unique identifier of the "parent" stream.
	ParentIDs        id.Slice                     `json:"parentIds"              bson:"parentIds"`              // List of all parent IDs, including the current parent.  This is used to generate "breadcrumbs" for the Stream.
	Rank             int                          `json:"rank"                   bson:"rank"`                   // If Template uses a custom sort order, then this is the value used to determine the position of this Stream.
	NavigationID     string                       `json:"navigationId"           bson:"navigationId"`           // Unique identifier of the "top-level" Stream that this record falls within.
	TemplateID       string                       `json:"templateId"             bson:"templateId"`             // Unique identifier (name) of the Template to use when building this Stream in HTML.
	ParentTemplateID string                       `json:"parentTemplateId"       bson:"parentTemplateId"`       // Unique identifier (name) of the parent's Template.
	StateID          string                       `json:"stateId"                bson:"stateId"`                // Unique identifier of the State this Stream is in.  This is used to populate the State information from the Template service at load time.
	SocialRole       string                       `json:"socialRole,omitempty"   bson:"socialRole,omitempty"`   // Role to use for this Stream in social integrations (Article, Note, Image, etc)
	Permissions      mapof.Object[sliceof.String] `json:"permissions,omitempty"  bson:"permissions,omitempty"`  // Permissions for which users can access this stream.
	DefaultAllow     id.Slice                     `json:"defaultAllow,omitempty" bson:"defaultAllow,omitempty"` // List of Groups that are allowed to perform the 'default' (view) action.  This is used to query general access to the Stream from the database, before performing server-based authentication.
	URL              string                       `json:"url,omitempty"          bson:"url,omitempty"`          // URL of the original document
	Token            string                       `json:"token,omitempty"        bson:"token,omitempty"`        // Unique value that identifies this element in the URL
	Label            string                       `json:"label,omitempty"        bson:"label,omitempty"`        // Label/Title of the document
	Summary          string                       `json:"summary,omitempty"      bson:"summary,omitempty"`      // Brief summary of the document
	ImageURL         string                       `json:"imageUrl,omitempty"     bson:"imageUrl,omitempty"`     // URL of the cover image for this document's image
	Content          Content                      `json:"content,omitempty"      bson:"content,omitempty"`      // Body content object for this Stream.
	Widgets          set.Slice[StreamWidget]      `json:"widgets,omitempty"      bson:"widgets,omitempty"`      // Additional widgets to include when building this Stream.
	Tags             sliceof.Object[Tag]          `json:"tags,omitempty"         bson:"tags,omitempty"`         // List of tags that are associated with this document
	Data             mapof.Any                    `json:"data,omitempty"         bson:"data,omitempty"`         // Set of data to populate into the Template.  This is validated by the JSON-Schema of the Template.
	AttributedTo     PersonLink                   `json:"attributedTo,omitempty" bson:"attributedTo,omitempty"` // List of people who are attributed to this document
	Context          string                       `json:"context,omitempty"      bson:"context,omitempty"`      // Context of this document (usually a URL)
	InReplyTo        string                       `json:"inReplyTo,omitempty"    bson:"inReplyTo"`              // If this stream is a reply to another stream or web page, then this links to the original document.
	PublishDate      int64                        `json:"publishDate"            bson:"publishDate"`            // Unix timestamp of the date/time when this document is/was/will be first available on the domain.
	UnPublishDate    int64                        `json:"unpublishDate"          bson:"unpublishDate"`          // Unix timestemp of the date/time when this document will no longer be available on the domain.
	journal.Journal  `bson:",inline"`
}

Stream corresponds to a top-level path on any Domain.

func NewStream

func NewStream() Stream

NewStream returns a fully initialized Stream object.

func (*Stream) ActivityPubAnnouncedURL added in v0.6.0

func (stream *Stream) ActivityPubAnnouncedURL() string

func (Stream) ActivityPubDislikesURL added in v0.6.0

func (stream Stream) ActivityPubDislikesURL() string

func (*Stream) ActivityPubFollowersURL added in v0.6.0

func (stream *Stream) ActivityPubFollowersURL() string

func (*Stream) ActivityPubInboxURL added in v0.6.0

func (stream *Stream) ActivityPubInboxURL() string

func (Stream) ActivityPubLikesURL added in v0.6.0

func (stream Stream) ActivityPubLikesURL() string

func (*Stream) ActivityPubOutboxURL added in v0.6.0

func (stream *Stream) ActivityPubOutboxURL() string

func (Stream) ActivityPubRepliesURL added in v0.6.0

func (stream Stream) ActivityPubRepliesURL() string

func (Stream) ActivityPubResponses added in v0.6.0

func (stream Stream) ActivityPubResponses(responseType string) string

func (Stream) ActivityPubSharesURL added in v0.6.0

func (stream Stream) ActivityPubSharesURL() string

func (Stream) ActivityPubType added in v0.6.0

func (stream Stream) ActivityPubType() string

func (Stream) ActivityPubURL added in v0.6.0

func (stream Stream) ActivityPubURL() string

func (*Stream) AssignPermission

func (stream *Stream) AssignPermission(role string, groupID primitive.ObjectID)

AssignPermissions assigns a role to a group

func (*Stream) DefaultAllowAnonymous

func (stream *Stream) DefaultAllowAnonymous() bool

DefaultAllowAnonymous returns TRUE if a Stream's default action (VIEW) is visible to anonymous visitors

func (stream *Stream) DocumentLink() DocumentLink

func (*Stream) GetPointer added in v0.6.0

func (stream *Stream) GetPointer(name string) (any, bool)

func (Stream) GetRank added in v0.6.0

func (stream Stream) GetRank() int64

func (*Stream) GetSort

func (stream *Stream) GetSort(fieldName string) any

GetSort returns the sortable value for this stream, based onthe provided fieldName

func (*Stream) GetStringOK

func (stream *Stream) GetStringOK(name string) (string, bool)

func (*Stream) HasParent

func (stream *Stream) HasParent() bool

HasParent returns TRUE if this Stream has a valid parentID

func (*Stream) ID

func (stream *Stream) ID() string

ID returns the primary key of this object

func (*Stream) IsPublished

func (stream *Stream) IsPublished() bool

IsPublished rturns TRUE if this Stream is currently published

func (stream *Stream) Permalink() string

func (*Stream) PermissionGroups

func (stream *Stream) PermissionGroups(roles ...string) []primitive.ObjectID

PermissionGroups returns all groups that match the provided roles

func (*Stream) PermissionRoles

func (stream *Stream) PermissionRoles(groupIDs ...primitive.ObjectID) []string

PermissionRoles returns a unique list of all roles that the provided groups can access.

func (*Stream) PublishActivity added in v0.6.0

func (stream *Stream) PublishActivity() string

PublishActivity returns the ActivityType that should be used when publishing this Stream (either Create or Update)

func (*Stream) Roles

func (stream *Stream) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization

func (*Stream) SetAttributedTo added in v0.6.0

func (stream *Stream) SetAttributedTo(person PersonLink)

SetAttributedTo sets the list of people that this Stream is attributed to

func (*Stream) SetState added in v0.6.0

func (stream *Stream) SetState(stateID string)

func (*Stream) SetString

func (stream *Stream) SetString(name string, value string) bool

func (*Stream) SimplePermissionModel

func (stream *Stream) SimplePermissionModel() mapof.Any

SimplePermissionModel returns a model object for displaying Simple Sharing.

func (*Stream) State

func (stream *Stream) State() string

State returns the current state of this Stream. It is part of the implementation of the RoleStateEmulator interface

func (Stream) Toot added in v0.6.0

func (stream Stream) Toot() object.Status

func (*Stream) WidgetByID

func (stream *Stream) WidgetByID(streamWidgetID primitive.ObjectID) StreamWidget

func (*Stream) WidgetsByLocation

func (stream *Stream) WidgetsByLocation(location string) []StreamWidget

type StreamActor added in v0.6.0

type StreamActor struct {
	SocialRole         string `json:"social-role"          bson:"socialRole"`         // StreamActor Role to use for this Template in social integrations (Person, Organization, Application, etc.)
	RSS                bool   `json:"rss"                  bson:"rss"`                // If TRUE, Generate RSS/Atom/JSONFeed/WebSub endpoints for this actor and its children
	BoostInbox         bool   `json:"boost-inbox"          bson:"boostInbox"`         // If TRUE, Broadcast all events sent to this Stream to all Followers
	BoostFollowersOnly bool   `json:"boost-followers-only" bson:"boostFollowersOnly"` // If TRUE, Broadcast messages from Followers only (not from other sources)
	BoostChildren      bool   `json:"boost-children"       bson:"boostChildren"`      // If TRUE, Broadcast add/update/delete events on child Streams to Followers
	PublishFollowers   bool   `json:"publish-followers"    bson:"publishFollowers"`   // If TRUE, Follower list is published via ActivityPub
}

func (StreamActor) IsNil added in v0.6.0

func (actor StreamActor) IsNil() bool

IsNull returns TRUE if this actor is nil (or undefined)

func (StreamActor) JSONLD added in v0.6.0

func (actor StreamActor) JSONLD(stream *Stream) mapof.Any

func (StreamActor) NotNil added in v0.6.0

func (actor StreamActor) NotNil() bool

NotNil returns TRUE if this actor has been defined (and should be executed).

type StreamSummary

type StreamSummary struct {
	ObjectID       primitive.ObjectID `json:"streamId"               bson:"_id"`                    // Unique identifier of this Stream.  (NOT USED PUBLICLY)
	ParentObjectID primitive.ObjectID `json:"parentId"               bson:"parentId"`               // Unique identifier of the "parent" stream. (NOT USED PUBLICLY)
	Token          string             `json:"token"                  bson:"token"`                  // Unique value that identifies this element in the URL
	TemplateID     string             `json:"templateId"             bson:"templateId"`             // Unique identifier (name) of the Template to use when building this Stream in HTML.
	URL            string             `json:"url,omitempty"          bson:"url,omitempty"`          // URL of the original document
	Label          string             `json:"label,omitempty"        bson:"label,omitempty"`        // Label/Title of the document
	Summary        string             `json:"summary,omitempty"      bson:"summary,omitempty"`      // Brief summary of the document
	Content        Content            `json:"content,omitempty"      bson:"content,omitempty"`      // Content of the document
	Data           mapof.Any          `json:"data,omitempty"         bson:"data,omitempty"`         // Additional data that is specific to the Template used to build this Stream
	ImageURL       string             `json:"imageUrl,omitempty"     bson:"imageUrl,omitempty"`     // URL of the cover image for this document's image
	AttributedTo   PersonLink         `json:"attributedTo,omitempty" bson:"attributedTo,omitempty"` // List of people who are attributed to this document
	InReplyTo      string             `json:"inReplyTo,omitempty"    bson:"inReplyTo,omitempty"`    // If this stream is a reply to another stream or web page, then this links to the original document.
	PublishDate    int64              `json:"publishDate"            bson:"publishDate"`            // Date when this stream was published
	Rank           int                `json:"rank"                   bson:"rank"`                   // If Template uses a custom sort order, then this is the value used to determine the position of this Stream.
}

StreamSummary represents a partial stream record (used for lists)

func NewStreamSummary

func NewStreamSummary() StreamSummary

NewStream returns a fully initialized Stream object.

func (StreamSummary) Author added in v0.6.0

func (summary StreamSummary) Author() PersonLink

func (StreamSummary) ContentHTML added in v0.6.0

func (summary StreamSummary) ContentHTML() string

func (StreamSummary) ContentRaw added in v0.6.0

func (summary StreamSummary) ContentRaw() string

func (StreamSummary) Fields

func (summary StreamSummary) Fields() []string

func (StreamSummary) ID added in v0.6.0

func (summary StreamSummary) ID() string

func (StreamSummary) ParentID

func (summary StreamSummary) ParentID() string

func (StreamSummary) StreamID

func (summary StreamSummary) StreamID() string

type StreamWidget

type StreamWidget struct {
	StreamWidgetID primitive.ObjectID `json:"streamWidgetId" bson:"streamWidgetId"`
	Type           string             `json:"type"           bson:"type"`
	Location       string             `json:"location"       bson:"location"`
	Label          string             `json:"label"          bson:"label"`
	Data           mapof.Any          `json:"data"           bson:"data"`

	// These values are not stored in the database, but injected during building
	Stream *Stream `json:"-" bson:"-"`
	Widget Widget  `json:"-" bson:"-"`
}

func NewStreamWidget

func NewStreamWidget(widgetType string, label string, location string) StreamWidget

func (*StreamWidget) GetPointer added in v0.6.0

func (x *StreamWidget) GetPointer(key string) (any, bool)

func (StreamWidget) GetStringOK

func (x StreamWidget) GetStringOK(key string) (string, bool)

func (StreamWidget) ID added in v0.6.0

func (widget StreamWidget) ID() string

ID returns the string representation of the StreamWidgetID This method satisfies the set.Value interface

func (StreamWidget) IsNew

func (widget StreamWidget) IsNew() bool

func (*StreamWidget) SetString

func (x *StreamWidget) SetString(key string, value string) bool

type Tag added in v0.6.0

type Tag struct {
	Type string `json:"type"` // Type of Tag (e.g. "Hashtag", "Mention")
	Name string `json:"name"` // Value to display (e.g. "#hashtag", "@mention")
	Href string `json:"href"` // URL to link to (e.g. "/hashtag/hashtag", "/user/username")
}

func NewTag added in v0.6.0

func NewTag() Tag

func (*Tag) GetPointer added in v0.6.0

func (tag *Tag) GetPointer(name string) (any, bool)

func (Tag) JSONLD added in v0.6.0

func (tag Tag) JSONLD() mapof.Any

type Template

type Template struct {
	TemplateID         string               `json:"templateId"         bson:"templateId"`         // Internal name/token other objects (like streams) will use to reference this Template.
	URL                string               `json:"url"                bson:"url"`                // URL where this template is published
	TemplateRole       string               `json:"templateRole"       bson:"templateRole"`       // Role that this Template performs in the system.  Used to match which streams can be contained by which other streams.
	SocialRole         string               `json:"socialRole"         bson:"socialRole"`         // Role to use for this Template in social integrations (Article, Note, etc)
	Model              string               `json:"model"              bson:"model"`              // Type of model object that this template works with. (Stream, User, Group, Domain, etc.)
	Extends            sliceof.String       `json:"extends"            bson:"extends"`            // List of templates that this template extends.  The first template in the list is the most important, and the last template in the list is the least important.
	ContainedBy        sliceof.String       `json:"containedBy"        bson:"containedBy"`        // Slice of Templates that can contain Streams that use this Template.
	Label              string               `json:"label"              bson:"label"`              // Human-readable label used in management UI.
	Description        string               `json:"description"        bson:"description"`        // Human-readable long-description text used in management UI.
	Category           string               `json:"category"           bson:"category"`           // Human-readable category (grouping) used in management UI.
	Icon               string               `json:"icon"               bson:"icon"`               // Icon image used in management UI.
	Sort               int                  `json:"sort"               bson:"sort"`               // Sort order used in management UI.
	ChildSortType      string               `json:"childSortType"      bson:"childSortType"`      // SortType used to display children
	ChildSortDirection string               `json:"childSortDirection" bson:"childSortDirection"` // Sort direction "asc" or "desc" (Default is ascending)
	WidgetLocations    sliceof.String       `json:"widget-locations"   bson:"widgetLocations"`    // List of locations where widgets can be placed.  Common values are: "TOP", "BOTTOM", "LEFT", "RIGHT"
	Schema             schema.Schema        `json:"schema"             bson:"schema"`             // JSON Schema that describes the data required to populate this Template.
	States             mapof.Object[State]  `json:"states"             bson:"states"`             // Map of States (by state.ID) that Streams of this Template can be in.
	AccessRoles        mapof.Object[Role]   `json:"accessRoles"        bson:"accessRoles"`        // Map of custom roles defined by this Template.
	Actions            mapof.Object[Action] `json:"actions"            bson:"actions"`            // Map of actions that can be performed on streams of this Template
	HTMLTemplate       *template.Template   `json:"-"                  bson:"-"`                  // Compiled HTML template
	Bundles            mapof.Object[Bundle] `json:"bundles"            bson:"bundles"`            // Additional resources (JS, HS, CSS) reqired tp remder this Template.
	Resources          fs.FS                `json:"-"                  bson:"-"`                  // File system containing the template resources
	DefaultAction      string               `json:"defaultAction"      bson:"defaultAction"`      // Name of the action to be used when none is provided.  Also serves as the permissions for viewing a Stream.  If this is empty, it is assumed to be "view"
	Actor              StreamActor          `json:"actor"             bson:"actor"`               // ActivityPub Actor operated on behalf of this Template/Stream
}

Template represents an HTML template used for building Streams

func NewTemplate

func NewTemplate(templateID string, funcMap template.FuncMap) Template

NewTemplate creates a new, fully initialized Template object

func (*Template) Action

func (template *Template) Action(actionID string) (Action, bool)

Action returns the action object for a specified name

func (*Template) CanBeContainedBy

func (template *Template) CanBeContainedBy(templateRoles ...string) bool

CanBeContainedBy returns TRUE if this Streams using this Template can be nested inside of Streams using the Template named in the parameters

func (*Template) Default

func (template *Template) Default() Action

Default returns the default Action for this Template.

func (Template) ID

func (template Template) ID() string

ID implements the set.Value interface

func (*Template) Inherit

func (template *Template) Inherit(parent *Template)

func (*Template) IsValidWidgetLocation

func (template *Template) IsValidWidgetLocation(location string) bool

func (*Template) State

func (template *Template) State(stateID string) (State, bool)

State searches for the State in this Template that matches the provided StateID If found, it is returned along with a TRUE If not found, an empty state is returned along with a FALSE

type Theme

type Theme struct {
	ThemeID        string                  `json:"themeID"        bson:"themeID"`        // Internal name/token other objects (like streams) will use to reference this Theme.
	Extends        []string                `json:"extends" bson:"extends"`               // List of other themes that this theme extends
	Category       string                  `json:"category"       bson:"category"`       // Category of this theme (for grouping)
	Label          string                  `json:"label"          bson:"label"`          // Human-readable label for this theme
	Description    string                  `json:"description"    bson:"description"`    // Human-readable description for this theme
	Rank           int                     `json:"rank"           bson:"rank"`           // Sort order for this theme
	HTMLTemplate   *template.Template      `json:"-"              bson:"-"`              // HTML template for this theme
	Bundles        mapof.Object[Bundle]    `json:"bundles"        bson:"bundles"`        // // Additional resources (JS, HS, CSS) reqired tp remder this Theme.
	Resources      fs.FS                   `json:"-"              bson:"-"`              // File system containing the template resources
	Datasets       mapof.Object[mapof.Any] `json:"datasets"       bson:"datasets"`       // Datasets used by this theme
	StartupStreams []mapof.Any             `json:"startupStreams" bson:"startupStreams"` // Dataset of Streams to initialize when this theme is first chosen.
	StartupGroups  []mapof.Any             `json:"startupGroups"  bson:"startupGroups"`  // Dataset of Groups to initialize when this theme is first chosen.
	DefaultFolders []mapof.Any             `json:"defaultFolders" bson:"defaultFolders"` // Dataset of Folders to initialize when a User is added using this Theme.
	IsVisible      bool                    `json:"isVisible"      bson:"isVisible"`      // Is this theme visible to the site owners?
}

Theme represents an HTML template used for building all hard-coded application elements (but not dynamic streams)

func NewTheme

func NewTheme(templateID string, funcMap template.FuncMap) Theme

NewTheme creates a new, fully initialized Theme object

func (*Theme) Inherit added in v0.6.0

func (theme *Theme) Inherit(parent *Theme)

func (Theme) IsEmpty added in v0.6.0

func (theme Theme) IsEmpty() bool

func (Theme) IsPlaceholder added in v0.6.0

func (theme Theme) IsPlaceholder() bool

IsPlaceholder is a temporary function the SHOULD be removed once we have a sufficient number of well-defined themes. Until then, it's used to mark themes that are in the system but don't work yet.

func (Theme) LookupCode

func (theme Theme) LookupCode() form.LookupCode

type User

type User struct {
	UserID         primitive.ObjectID         `json:"userId"          bson:"_id"`                  // Unique identifier for this user.
	GroupIDs       id.Slice                   `json:"groupIds"        bson:"groupIds"`             // Slice of IDs for the groups that this user belongs to.
	ImageID        primitive.ObjectID         `json:"imageId"         bson:"imageId"`              // AttachmentID of this user's avatar image.
	DisplayName    string                     `json:"displayName"     bson:"displayName"`          // Name to be displayed for this user
	StatusMessage  string                     `json:"statusMessage"   bson:"statusMessage"`        // Status summary for this user
	Location       string                     `json:"location"        bson:"location"`             // Human-friendly description of this user's physical location.
	Links          sliceof.Object[PersonLink] `json:"links"           bson:"links"`                // Slice of links to profiles on other web services.
	ProfileURL     string                     `json:"profileUrl"      bson:"profileUrl"`           // Fully Qualified profile URL for this user (including domain name)
	EmailAddress   string                     `json:"emailAddress"    bson:"emailAddress"`         // Email address for this user
	Username       string                     `json:"username"        bson:"username"`             // This is the primary public identifier for the user.
	Password       string                     `json:"-"               bson:"password"`             // This password should be encrypted with BCrypt.
	Locale         string                     `json:"locale"          bson:"locale"`               // Language code for this user's preferred language.
	SignupNote     string                     `json:"signupNote"      bson:"signupNote,omitempty"` // Note that was included when this user signed up.
	FollowerCount  int                        `json:"followerCount"   bson:"followerCount"`        // Number of followers for this user
	FollowingCount int                        `json:"followingCount"  bson:"followingCount"`       // Number of users that this user is following
	RuleCount      int                        `json:"ruleCount"      bson:"ruleCount"`             // Number of users that this user is following
	IsOwner        bool                       `json:"isOwner"         bson:"isOwner"`              // If TRUE, then this user is a website owner with FULL privileges.
	IsPublic       bool                       `json:"isPublic"        bson:"isPublic"`             // If TRUE, then this user's profile is publicly available
	PasswordReset  PasswordReset              `                       bson:"passwordReset"`        // Most recent password reset information.

	journal.Journal `json:"-" bson:",inline"`
}

User represents a person or machine account that can own pages and sections.

func NewUser

func NewUser() User

NewUser returns a fully initialized User object.

func (*User) ActivityPubAvatarURL

func (user *User) ActivityPubAvatarURL() string

func (*User) ActivityPubBlockedURL

func (user *User) ActivityPubBlockedURL() string

func (*User) ActivityPubFollowersURL

func (user *User) ActivityPubFollowersURL() string

func (*User) ActivityPubFollowingURL

func (user *User) ActivityPubFollowingURL() string

func (*User) ActivityPubInboxURL

func (user *User) ActivityPubInboxURL() string

func (*User) ActivityPubLikedURL

func (user *User) ActivityPubLikedURL() string

func (*User) ActivityPubOutboxURL

func (user *User) ActivityPubOutboxURL() string

func (*User) ActivityPubPublicKeyURL

func (user *User) ActivityPubPublicKeyURL() string

func (*User) ActivityPubURL

func (user *User) ActivityPubURL() string

func (*User) Claims

func (user *User) Claims() jwt.Claims

Claims returns all access privileges given to this user. A part of the "steranko.User" interface.

func (User) Copy

func (user User) Copy() User

Copy returns a duplicate copy of this User NOTE: This must NOT be a pointer receiver, so that a true COPY of this record is returned.

func (User) GetJSONLD

func (user User) GetJSONLD() mapof.Any

func (*User) GetPassword

func (user *User) GetPassword() string

GetPassword returns the (encrypted) passsword for this User. A part of the "steranko.User" interface.

func (*User) GetPointer added in v0.6.0

func (user *User) GetPointer(name string) (any, bool)

func (*User) GetProfileURL

func (user *User) GetProfileURL() string

func (User) GetRank added in v0.6.0

func (user User) GetRank() int64

func (*User) GetStringOK

func (user *User) GetStringOK(name string) (string, bool)

func (*User) GetUsername

func (user *User) GetUsername() string

GetUsername returns the username for this User. A part of the "steranko.User" interface.

func (*User) ID

func (user *User) ID() string

ID returns the primary key for this record

func (*User) JSONFeedURL

func (user *User) JSONFeedURL() string
func (user User) PersonLink() PersonLink

func (*User) Roles

func (user *User) Roles(authorization *Authorization) []string

Roles returns a list of all roles that match the provided authorization

func (*User) SetPassword

func (user *User) SetPassword(password string)

SetPassword updates the password for this User. A part of the "steranko.User" interface.

func (*User) SetString

func (user *User) SetString(name string, value string) bool

func (*User) SetUsername

func (user *User) SetUsername(username string)

SetUsername updates the username for this User. A part of the "steranko.User" interface.

func (*User) State

func (user *User) State() string

State returns the current state of this object. For users, there is no state, so it returns ""

func (User) Summary

func (user User) Summary() UserSummary

Summary generates a lightweight summary of this user record.

func (User) Toot added in v0.6.0

func (user User) Toot() object.Account

type UserResponseSummary added in v0.6.0

type UserResponseSummary struct {
	Announce bool
	Like     bool
	Dislike  bool
}

UserResponseSummary is a summary object of the User's response(s) to a particular ActivityStream

func NewUserResponseSummary added in v0.6.0

func NewUserResponseSummary() UserResponseSummary

NewUserResponseSummary returns a fully initialized UserResponseSummary

func (*UserResponseSummary) SetResponse added in v0.6.0

func (summary *UserResponseSummary) SetResponse(responseType string, value bool)

type UserSummary

type UserSummary struct {
	UserID       primitive.ObjectID `bson:"_id"`
	DisplayName  string             `bson:"displayName"`
	EmailAddress string             `bson:"emailAddress"`
	Username     string             `bson:"username"`
	ImageURL     string             `bson:"imageUrl"`
	ProfileURL   string             `bson:"profileUrl"`
}

UserSummary is used as a lightweight, read-only summary of a user record.

func NewUserSummary

func NewUserSummary() UserSummary

func (UserSummary) Fields

func (userSummary UserSummary) Fields() []string

type Widget

type Widget struct {
	WidgetID     string               `json:"widgetId"     bson:"widgetId"`     // Unique identifier for this widget
	Label        string               `json:"label"        bson:"label"`        // Human-readable label for this widget
	Description  string               `json:"description"  bson:"description"`  // Human-readable description for this widget
	Schema       schema.Schema        `json:"schema"       bson:"schema"`       // Custom data schema to use for this widget
	Form         form.Element         `json:"form"         bson:"form"`         // Property/Settings form for this widget
	HTMLTemplate *template.Template   `json:"htmlTemplate" bson:"htmlTemplate"` // HTML template for this widget
	Bundles      mapof.Object[Bundle] `json:"bundles"      bson:"bundles"`      // List of bundles that this widget uses
	Resources    fs.FS                `json:"-"            bson:"-"`            // File system containing the template resources
}

func NewWidget

func NewWidget(widgetID string, funcMap template.FuncMap) Widget

func (Widget) IsEditable added in v0.6.0

func (widget Widget) IsEditable() bool

Directories

Path Synopsis
Package Step encapsulates the DATA required for each pipeline step in the builder.
Package Step encapsulates the DATA required for each pipeline step in the builder.

Jump to

Keyboard shortcuts

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