model

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: AGPL-3.0 Imports: 45 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 AttachmentMediaTypeAny = "any"

AttachmentMediaTypeOther represents an attachment that is any type

View Source
const AttachmentMediaTypeAudio = "audio"

AttachmentMediaTypeAudio represents an attachment that is audio

View Source
const AttachmentMediaTypeDocument = "document"

AttachmentMediaTypeDocument represents an attachment that is a document

View Source
const AttachmentMediaTypeImage = "image"

AttachmentMediaTypeImage represents an attachment that is an image

View Source
const AttachmentMediaTypeVideo = "video"

AttachmentMediaTypeVideo represents an attachment that is a video

View Source
const AttachmentObjectTypeDomain = "Domain"

AttachmentObjectTypeDomain represents an attachment that is owned by a Domain

View Source
const AttachmentObjectTypeSearchTag = "SearchTag"

AttachmentObjectTypeSearchTag represents an attachment that is owned by a SearchTag

View Source
const AttachmentObjectTypeStream = "Stream"

AttachmentObjectTypeStream represents an attachment that is owned by a Stream

View Source
const AttachmentObjectTypeUser = "User"

AttachmentObjectTypeUser represents an attachment that is owned by a User

View Source
const AttachmentStatusReady = "READY"

AttachmentStatusReady represents an attachment that has been transcoded (if necessary) and is ready to download or stream

View Source
const AttachmentStatusWorking = "WORKING"

AttachmentStatusWorking represents an attachment that is currently being processed and cannot be downloaded yet.

View Source
const ConnectionProviderGiphy = "GIPHY"

ConnectionProviderGiphy represents an API connection to the https://giphy.com service for generating animated GIFs.

View Source
const ConnectionProviderStripe = "STRIPE"

ConnectionProviderStripe represents an API connection to the https://stripe.com service for processing payments.

View Source
const ConnectionProviderUnsplash = "UNSPLASH"

ConnectionProviderUnsplash represents an API connection to the https://unsplash.com service for generating photographs.

View Source
const ConnectionTypeImage = "IMAGE"

ConnectionTypeIMage represents a provider/connection that can be used to generate images.

View Source
const ConnectionTypePayment = "PAYMENT"

ConnectionTypePayment represents a provider/connection that can be used to process payments.

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 DomainColorModeAuto = "AUTO"

DomainColorModeAuto represents color mode that is determined automatically by the client's settings

View Source
const DomainColorModeDark = "DARK"

DomainColorModeDark represents dark color mode

View Source
const DomainColorModeLight = "LIGHT"

DomainColorModeLight represents light color mode

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 FollowerMethodActivityPub = "ACTIVITYPUB"

FollowerMethodActivityPub represents a Follower subscription that receives real-time updates via ActivityPub https://www.w3.org/TR/activitypub/

View Source
const FollowerMethodEmail = "EMAIL"

FollowerMethodEmail represents a Follower subscription that received real-time updates via email

View Source
const FollowerMethodWebSub = "WEBSUB"

FollowerMethodWebSub represents a Follower subscription that receives real-time updates via WebSub https://websub.rocks

View Source
const FollowerStateActive = "ACTIVE"

FollowerStateActive represents an active Follower who is currently receiving updates from the Stream

View Source
const FollowerStatePending = "PENDING"

FollowerStatePending represents an inactive Follower who has yet to confirm their subscription status (e.g. via email confirmation)

View Source
const FollowerTypeSearch = "Search"

FollowerTypeSearch represents a Follower that is following a Search Query

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 FollowingMethodActivityPub = "ACTIVITYPUB"

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

View Source
const FollowingMethodPoll = "POLL"

FollowingMethodPoll represents a subscription that must be polled for updates

View Source
const FollowingMethodWebSub = "WEBSUB"

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

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 MimeTypeJSONLDWithProfile = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
View Source
const MimeTypeJSONResourceDescriptor = "application/jrd+json"

https://datatracker.ietf.org/doc/html/rfc7033#section-10.2

View Source
const MimeTypeJSONResourceDescriptorWithCharset = "application/jrd+json; charset=utf-8"

https://datatracker.ietf.org/doc/html/rfc7033#section-10.2 With charset extension to match Mastodon

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 SearchTagStateAllowed = 1

SearchTagStateAllowed represents a SearchTag that is allowed on the search index

View Source
const SearchTagStateBlocked = -1

SearchTagStateBlocked represents a SearchTag that is blocked from the search index

View Source
const SearchTagStateFeatured = 2

SearchTagStateFeatured represents a SearchTag that is featured on the search index

View Source
const SearchTagStateWaiting = 0

SearchTagStateWaiting represents a SearchTag that is waiting to be allowed on the search index

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

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

View Source
const UserMapIDStripe = "STRIPE"

UserMapIDStripe identifies the Stripe CustomerID for a User https://docs.stripe.com/api/customers/object#customer_object-id

View Source
const WebhookEventStreamCreate = "stream:create"

WebhookEventStreamCreate is triggered when a new Stream record is created

View Source
const WebhookEventStreamDelete = "stream:delete"

WebhookEventStreamDelete is triggered when an existing Stream record is deleted

View Source
const WebhookEventStreamPublish = "stream:publish"

WebhookEventStreamPublish is triggered when a Stream is published

View Source
const WebhookEventStreamPublishUndo = "stream:publish:undo"

WebhookEventStreamUnpublish is triggered when a Stream is unpublished

View Source
const WebhookEventStreamSyndicate = "stream:syndicate"

WebhookEventStreamSyndicate is triggered when a Stream is syndicated

View Source
const WebhookEventStreamSyndicateUndo = "stream:syndicate:undo"

WebhookEventStreamSyndicateUndo is triggered when a Stream's syndication is undone

View Source
const WebhookEventStreamUpdate = "stream:update"

WebhookEventStreamUpdate is triggered when an existing Stream record is updated

View Source
const WebhookEventUserCreate = "user:create"

WebhookEventUserCreate is triggered when a new User record is created

View Source
const WebhookEventUserDelete = "user:delete"

WebhookEventUserDelete is triggered when an existing User record is deleted

View Source
const WebhookEventUserUpdate = "user:update"

WebhookEventUserUpdate is triggered when an existing User record is updated

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 AttachmentRulesSchema added in v0.7.0

func AttachmentRulesSchema() schema.Element

func AttachmentSchema

func AttachmentSchema() schema.Element

AttachmentSchema returns a validating schema for Attachment objects.

func ConnectionSchema added in v0.7.0

func ConnectionSchema() 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 OutboxMessageSchema added in v0.7.0

func OutboxMessageSchema() schema.Element

func OutboxMessageSummaryFields added in v0.6.0

func OutboxMessageSummaryFields() []string

func PasswordResetSchema

func PasswordResetSchema() schema.Element

PasswordResetSchema returns the data schema for PasswordReset objects

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 SearchTagSchema added in v0.7.0

func SearchTagSchema() schema.Element

SearchTagSchema returns a validating schema for SearchTag objects

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 ToToken added in v0.7.0

func ToToken(value string) string

ToToken returns a normalized version of the input string, stripping out all non-alphanumeric characters, and converting all characters to lowercase.

func UserSchema

func UserSchema() schema.Element

func UserSummaryFields

func UserSummaryFields() []string

func WebhookFields added in v0.7.0

func WebhookFields() []string

func WebhookSchema added in v0.7.0

func WebhookSchema() schema.Element

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

UsernameOrID returns the best identifier we can find for an Actor: either the Actor' username, if it exists, or the Actor's ID

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
	Category     string             `bson:"category"`    // Category of the file (defined by the Template)
	Label        string             `bson:"label"`       // User-defined label for the attachment
	Description  string             `bson:"description"` // User-defined description for the attachment
	URL          string             `bson:"url"`         // URL where the file is stored
	Status       string             `bson:"status"`      // Status of the attachment (READY, WORKING)
	Rules        AttachmentRules    `bson:"rules"`       // Rules for downloading this attachment
	Height       int                `bson:"height"`      // Height of the media file (if applicable)
	Width        int                `bson:"width"`       // Width of the media file (if applicable)
	Duration     int                `bbson:"duration"`   // Duration of the media file (if applicable)
	Rank         int                `bson:"rank"`        // The sort order to display the attachments in.

	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) FileSpec added in v0.7.0

func (attachment Attachment) FileSpec(address *url.URL) mediaserver.FileSpec

func (*Attachment) GetPointer added in v0.7.0

func (attachment *Attachment) GetPointer(name string) (any, bool)

GetPointer implements the schema.PointerGetter interface, and allows read/write access to (most) fields of the Attachment object.

func (*Attachment) GetStringOK

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

GetStringOK implements the schema.StringGetter interface, and returns string values for several fields of the Attachment object.

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) SetRules added in v0.7.0

func (attachment *Attachment) SetRules(width int, height int, extensions []string)

func (*Attachment) SetString

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

SetString implemments the schema.StringSetter interface, and allows setting string values for several fields of the Attachment object.

func (*Attachment) SetURL added in v0.6.0

func (attachment *Attachment) SetURL(host string)

type AttachmentRules added in v0.7.0

type AttachmentRules struct {
	Extensions sliceof.String // Allowed extensions.  The first value is used as the default.
	Width      int            // Fixed width for all downloads
	Height     int            // Fixed height for all downloads
	Bitrate    int
}

AttachmentRules defines the rules for downloading an attachment

func NewAttachmentRules added in v0.7.0

func NewAttachmentRules() AttachmentRules

NewAttachmentRules returns a fully initialized AttachmentRules object

func (AttachmentRules) FileSpec added in v0.7.0

func (rules AttachmentRules) FileSpec(address *url.URL, originalExtension string) mediaserver.FileSpec

FileSpec applies the attachment rules to a request, and returns the best-matching FileSpec definition for mediaserver

func (*AttachmentRules) GetPointer added in v0.7.0

func (rules *AttachmentRules) GetPointer(name string) (any, bool)

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 Connection added in v0.7.0

type Connection struct {
	ConnectionID primitive.ObjectID `bson:"_id"`        // Unique ID for this connection
	ProviderID   string             `bson:"providerId"` // ID of the provider that this credential accesses
	Type         string             `bson:"type"`       // Type of connection (e.g. "payment")
	Data         mapof.String       `bson:"data"`       // Unique data for this credential
	Token        *oauth2.Token      `bson:"token"`      // OAuth2 Token (if necessary)
	Active       bool               `bson:"active"`     // Is this credential active?

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

Connection 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 NewConnection added in v0.7.0

func NewConnection() Connection

NewConnection returns a fully initialized Connection object.

func (*Connection) GetPointer added in v0.7.0

func (connection *Connection) GetPointer(name string) (any, bool)

func (Connection) GetStringOK added in v0.7.0

func (connection Connection) GetStringOK(name string) (string, bool)

func (Connection) ID added in v0.7.0

func (connection Connection) ID() string

ID implements the set.Value interface

func (*Connection) SetString added in v0.7.0

func (connection *Connection) SetString(name string, value string) bool

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 DatasetMap added in v0.7.0

type DatasetMap map[string]form.ReadOnlyLookupGroup
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
	IconURL      string             `json:"iconUrl,omitempty"      bson:"iconUrl,omitempty"`       // URL of the icon image for this document
	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.
	IconID           primitive.ObjectID              `bson:"iconId"`           // ID of the logo to use for this domain
	Hostname         string                          `bson:"hostname"`         // Hostname of this domain (e.g. "example.com")
	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
	RegistrationID   string                          `bson:"registrationId"`   // ID of the signup template to use for this domain
	InboxID          string                          `bson:"inboxId"`          // ID of the default inbox template to use for this domain
	OutboxID         string                          `bson:"outboxId"`         // ID of the default outbox template 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.
	ThemeData        mapof.Any                       `bson:"themeData"`        // Custom data stored in this domain
	RegistrationData mapof.String                    `bson:"registrationData"` // Custom data for signup template stored in this domain
	ColorMode        string                          `bson:"colorMode"`        // Color mode for this domain (e.g. "LIGHT", "DARK", or "AUTO")
	Data             mapof.String                    `bson:"data"`             // Custom data stored in this domain
	DatabaseVersion  uint                            `bson:"databaseVersion"`  // Version of the database schema
	Syndication      sliceof.Object[form.LookupCode] `bson:"syndication"`      // List of external services that this domain can syndicate to
	PrivateKey       string                          `bson:"privateKey"`       // Private key for this domain
	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) 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) HasRegistrationForm added in v0.7.0

func (domain *Domain) HasRegistrationForm() bool

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

func (*Domain) Host added in v0.7.0

func (domain *Domain) Host() string

Host returns a usable URL for this domain, including the HTTP(S) protocol and hostname

func (*Domain) ID

func (domain *Domain) ID() string

ID returns the primary key of this object

func (*Domain) IconURL added in v0.7.0

func (domain *Domain) IconURL() string

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) SetString

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

type Email added in v0.7.0

type Email struct {
	EmailID   string             // Unique identifier for this email.
	EmailRole string             // Role of the email - for system emails that may have multiple options
	Model     string             // Object type that this email is associated with
	Headers   *template.Template // Additional email header values
	To        *template.Template // Template for the email address to send this email to
	Subject   *template.Template // Template for the email subject
	Body      *template.Template // Template for the email body
	Resources fs.FS              // File system containing additional files (like images) required by this email
}

func NewEmail added in v0.7.0

func NewEmail(emailID string, funcMap template.FuncMap) Email

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
	ParentType string             `json:"type"       bson:"type"`       // Type of record being followed (e.g. "User", "Stream", or "Search")
	ParentID   primitive.ObjectID `json:"parentId"   bson:"parentId"`   // Unique identifier for the Stream that is being followed (including user's outboxes)
	StateID    string             `json:"stateId"    bson:"stateId"`    // Unique identifier for the State of this Follower ("ACTIVE", "PENDING")
	Method     string             `json:"method"     bson:"method"`     // Method of follower (e.g. "POLL", "WEBSUB", "RSS-CLOUD", "ACTIVITYPUB", "EMAIL")
	Format     string             `json:"format"     bson:"format"`     // Format of the data being followed (e.g. "ATOM", "HTML", "JSON", "RSS", "XML")
	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) MarshalMap added in v0.7.0

func (follower Follower) MarshalMap() mapof.Any

MarshalMap returns a mapof.Any representation of this Follower

func (Follower) ParentURL added in v0.7.0

func (follower Follower) ParentURL(host string) string

ParentURL returns the URL of the parent object that this Follower is following.

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.

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 ""

func (*Follower) UnmarshalMap added in v0.7.0

func (follower *Follower) UnmarshalMap(data mapof.Any)

UnmarshalMap populates this Follower from a mapof.Any object

func (follower Follower) UnsubscribeLink(host string) string

UnsubscribeLink returns a URL where an Email Follower can unsubscribe. It returns an empty string for all other follower types (ActivityPub, WebSub, etc.)

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.
	Username        string             `json:"username"        bson:"username"`        // Username of the actor that is being followed (@username@server.social).
	ProfileURL      string             `json:"profileUrl"      bson:"profileUrl"`      // Updated, computer-facing URL that is being followed.
	IconURL         string             `json:"iconUrl"         bson:"iconUrl"`         // URL of an the avatar/icon 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

func (Following) UsernameOrID added in v0.7.0

func (following Following) UsernameOrID() string

type FollowingSummary

type FollowingSummary struct {
	FollowingID primitive.ObjectID `bson:"_id"`
	Username    string             `bson:"username"`
	URL         string             `bson:"url"`
	Label       string             `bson:"label"`
	Folder      string             `bson:"folder"`
	FolderID    primitive.ObjectID `bson:"folderId"`
	IconURL     string             `bson:"iconUrl"`
	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

func (FollowingSummary) UsernameOrID added in v0.7.0

func (summary FollowingSummary) UsernameOrID() string

type Group

type Group struct {
	GroupID primitive.ObjectID `json:"groupId" bson:"_id"`   // Unique identifier assigned by the database
	Token   string             `json:"token"   bson:"token"` // Uniqe token chosen by the administrator
	Label   string             `json:"label"   bson:"label"` // Human-readable label for this group.

	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"`       // Unique identifier for this key (used by MongoDB)
	KeyName   string             `bson:"keyName"`   // Name of this key (used by the application)
	Algorithm string             `bson:"algorithm"` // Algorithm used to generate this key (AES)
	Encrypted string             `bson:"encrypted"` // Encrypted value

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

JWTKey represents

func NewJWTKey added in v0.6.0

func NewJWTKey() JWTKey

NewJWTKey returns a fully initialized JWTKey object

func (JWTKey) ID added in v0.6.0

func (key JWTKey) ID() string

ID implements the data.Object interface, and

returns the unique identifier for this key

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)
	PublishDate int64                      `json:"publishDate"  bson:"publishDate,omitempty"` // Unix timestamp of the date/time when this Message was published
	ReadDate    int64                      `json:"readDate"     bson:"readDate"`              // Unix timestamp of the date/time when this Message was read.  If unread, this is MaxInt64.
	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.

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
	IconURL     string             `json:"iconUrl"     bson:"iconUrl,omitempty"`     // URL of the a avatar/icon image for this origin
}

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) Created added in v0.7.0

func (message OutboxMessage) Created() int64

func (OutboxMessage) Fields added in v0.6.0

func (summary OutboxMessage) Fields() []string

func (OutboxMessage) GetJSONLD added in v0.7.0

func (message OutboxMessage) GetJSONLD() mapof.Any

func (*OutboxMessage) GetPointer added in v0.7.0

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

func (*OutboxMessage) GetStringOK added in v0.7.0

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

func (OutboxMessage) ID added in v0.6.0

func (message OutboxMessage) ID() string

func (*OutboxMessage) SetString added in v0.7.0

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

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() PasswordReset

NewPasswordReset returns a fully initialized PasswordReset object.

func (PasswordReset) IsActive added in v0.7.0

func (reset PasswordReset) IsActive() bool

IsActive returns TRUE if this code exists and has not expired (i.e. people can still use it to reset their password)

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.

func (PasswordReset) NotActive added in v0.7.0

func (reset PasswordReset) NotActive() bool

NotActive returns TRUE if this code does not exist, or has expired (i.e. people cannot use it to reset their password)

func (*PasswordReset) RefreshExpireDate added in v0.7.0

func (reset *PasswordReset) RefreshExpireDate()

RefreshExpireDate extends the expiration date of the password reset code by 24 hours.

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
	Username     string             `json:"username,omitempty"     bson:"username,omitempty"`     // Username of the person (e.g. @user@domain.social)
	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
	IconURL      string             `json:"iconUrl,omitempty"      bson:"iconUrl,omitempty"`      // URL of the person's avatar/icon image
}
func NewPersonLink() PersonLink

func (PersonLink) GetJSONLD added in v0.6.0

func (person PersonLink) GetJSONLD() mapof.Any

GetJSONLD returns a JSON-LD representation of this Person.

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 "iconUrl" should be passed to this function. all others will return nil values

func (PersonLink) HasIconURL added in v0.7.0

func (person PersonLink) HasIconURL() bool

HasIconURL returns TRUE if this person has a non-empty icon

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) MarshalMap added in v0.7.0

func (person PersonLink) MarshalMap() mapof.Any

MarshalMap returns a mapof.Any representation of this PersonLink

func (PersonLink) NotEmpty added in v0.6.0

func (person PersonLink) NotEmpty() bool

NotEmpty returns TRUE if this record is not empty.

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

func (*PersonLink) UnmarshalMap added in v0.7.0

func (person *PersonLink) UnmarshalMap(data mapof.Any)

UnmarshalMap populates this PersonLink from a mapof.Any object

func (PersonLink) UsernameOrID added in v0.7.0

func (person PersonLink) UsernameOrID() string

UsernameOrID returns the best-available username for this Person

type Registration added in v0.7.0

type Registration struct {
	RegistrationID string               `json:"registrationId"     bson:"registrationId"` // Internal name/token other objects (like streams) will use to reference this Registration.
	Extends        sliceof.String       `json:"extends"            bson:"extends"`        // List of registrations that this registration extends.  The first registration in the list is the most important, and the last registration in the list is the least important.
	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.
	Icon           string               `json:"icon"               bson:"icon"`           // Icon image used in management UI.
	Sort           int                  `json:"sort"               bson:"sort"`           // Sort order used in management UI.
	Form           form.Element         `json:"form"               bson:"form"`           // Form used to edit custom data
	Schema         schema.Schema        `json:"schema"             bson:"schema"`         // JSON Schema that describes the data required to populate this Registration.
	Actions        mapof.Object[Action] `json:"actions"            bson:"actions"`        // Map of actions that can be performed on streams of this Registration
	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 Registration.
	Resources      fs.FS                `json:"-"                  bson:"-"`              // File system containing the registration resources
	AllowedFields  []string             `json:"allowedFields"      bson:"allowedFields"`  // List of fields that are allowed to be set by the user
}

Registration represents an HTML registration used for building Streams

func NewRegistration added in v0.7.0

func NewRegistration(registrationID string, funcMap template.FuncMap) Registration

NewRegistration creates a new, fully initialized Registration object

func (*Registration) Action added in v0.7.0

func (registration *Registration) Action(actionID string) (Action, bool)

Action returns the action object for a specified name

func (Registration) ID added in v0.7.0

func (registration Registration) ID() string

ID implements the set.Value interface

func (*Registration) Inherit added in v0.7.0

func (registration *Registration) Inherit(parent *Registration)

func (Registration) IsZero added in v0.7.0

func (registration Registration) IsZero() bool

type RegistrationTxn added in v0.7.0

type RegistrationTxn struct {
	DisplayName    string `form:"displayName"`    // required: User's DisplayName
	EmailAddress   string `form:"emailAddress"`   // required: User's EmailAddress
	Username       string `form:"username"`       // optional: User's Username
	Password       string `form:"password"`       // optional: User's Password
	StateID        string `form:"stateId"`        // optional: User's StateID
	InboxTemplate  string `form:"inboxTemplate"`  // optional: User's InboxTemplate
	OutboxTemplate string `form:"outboxTemplate"` // optional: User's OutboxTemplate
	AddGroups      string `form:"addGroups"`      // optional: Comma-separated list of GroupIDs to add the User to
	RemoveGroups   string `form:"removeGroups"`   // optional: Comma-separated list of GroupIDs to remove the User from
	Secret         string `form:"secret"`         // optional: Secret key used to validate the registration

	// Internal values assigned by the server
	UserID string `form:"-"` // optional: Unique identifier for the User to be created.  Prevents replay/reuse attacks
}

RegistrationTsn represents the data that is submitted when a User registers for a new account

func NewRegistrationTxn added in v0.7.0

func NewRegistrationTxn() RegistrationTxn

NewRegistrationTxn returns a fully initialized RegistrationTxn object

func ParseRegistrationFromClaims added in v0.7.0

func ParseRegistrationFromClaims(claims jwt.MapClaims) RegistrationTxn

func (RegistrationTxn) Claims added in v0.7.0

func (txn RegistrationTxn) Claims() jwt.MapClaims

func (RegistrationTxn) IsInvalid added in v0.7.0

func (txn RegistrationTxn) IsInvalid(secret string) bool

IsInvalid is the inverse of `IsValid`. It returns TRUE if the transaction is NOT VALID

func (RegistrationTxn) IsValid added in v0.7.0

func (txn RegistrationTxn) IsValid(secret string) bool

IsValid returns TRUE if all of the required fields are present and valid. The "secret" field is required, and if not empty, MUST match the `secret` value in the Transaction.

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 SearchResult added in v0.7.0

type SearchResult struct {
	SearchResultID primitive.ObjectID `bson:"_id"`          // SearchResultID is the unique identifier for a SearchResult.
	Type           string             `bson:"type"`         // Type is the ActivityPub object type (Person, Article, etc)
	URL            string             `bson:"url"`          // URL is the URL of the SearchResult.
	Name           string             `bson:"name"`         // Name is the name of the SearchResult.
	AttributedTo   string             `bson:"attributedTo"` // AttributedTo is the name (or username) of the creator of this SearchResult.
	Summary        string             `bson:"summary"`      // Summary is a short description of the SearchResult.
	IconURL        string             `bson:"icon"`         // IconURL is the URL of the icon for the SearchResult.
	TagNames       sliceof.String     `bson:"tagNames"`     // TagNames is a human-readable list of tags that are associated with this SearchResult.
	TagValues      sliceof.String     `bson:"tagValues"`    // TagValues is a machine-readable list of tag values that are associated with this SearchResult.
	FullText       string             `bson:"fullText"`     // FullText is the full text of the SearchResult.
	Rank           int64              `bson:"rank"`         // Rank is the rank of this SearchResult in the search index.
	Shuffle        int64              `bson:"shuffle"`      // Shuffle is a random number used to shuffle the search results.
	ReIndexDate    int64              `bson:"reindexDate"`  // ReIndexDate is the date that this SearchResult should be reindexed.

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

SearchResult represents a value in the search index

func NewSearchResult added in v0.7.0

func NewSearchResult() SearchResult

func (SearchResult) Fields added in v0.7.0

func (searchResult SearchResult) Fields() []string

func (SearchResult) ID added in v0.7.0

func (searchResult SearchResult) ID() string

ID returns the unique identifier for this SearchResult and implements the data.Object interface

func (SearchResult) IsZero added in v0.7.0

func (searchResult SearchResult) IsZero() bool

func (*SearchResult) Update added in v0.7.0

func (searchResult *SearchResult) Update(other SearchResult)

Update copies the values from another SearchResult into this SearchResult

type SearchTag added in v0.7.0

type SearchTag struct {
	SearchTagID primitive.ObjectID `bson:"_id"`     // SearchTagID is the unique identifier for a SearchTag.
	Group       string             `bson:"group"`   // Group is the type of tag (GENRE, MOOD, ACTIVITY, etc.)
	Name        string             `bson:"name"`    // Name used for this tag
	Value       string             `bson:"value"`   // Value is the normalized version of the tag name.
	Colors      sliceof.String     `bson:"colors"`  // Colors is a slice of one or more RGB Hex color to use for tags featured on search panels.
	Related     string             `bson:"related"` // Related is a list of other tags that are related to this tag.
	Notes       string             `bson:"notes"`   // Notes is a place for administrators to make notes about the tag.
	Rank        int                `bson:"rank"`    // Rank is the sort order of the SearchTag.
	StateID     int                `bson:"stateId"` // StateID represents the state that the tag is in. (FEATURED, ALLOWED, WAITING, BLOCKED)
	ImageID     primitive.ObjectID `bson:"imageId"` // AttachmentID is the unique identifier for the attachment that is associated with this tag.

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

SearchTag represents a tag that vistors can use to search for Users and Streams in the database.

func NewSearchTag added in v0.7.0

func NewSearchTag() SearchTag

NewSearchTag returns a fully initialized SearchTag object

func (SearchTag) Fields added in v0.7.0

func (searchTag SearchTag) Fields() []string

Fields returns a slice of field names to include in a batch search query.

func (*SearchTag) GetPointer added in v0.7.0

func (searchTag *SearchTag) GetPointer(name string) (any, bool)

GetPointer implements the schema.PointerGetter interface, and allows read/write access to many fields of a SearchTag object

func (SearchTag) GetStringOK added in v0.7.0

func (searchTag SearchTag) GetStringOK(name string) (string, bool)

GetStringOK implements the schema.StringGetter interface, and allows read access to many fields of a SearchTag object

func (SearchTag) ID added in v0.7.0

func (searchTag SearchTag) ID() string

ID returns the unique identifier for this SearchTag, implementing the data.Object interface.

func (SearchTag) ImageURL added in v0.7.0

func (searchTag SearchTag) ImageURL() string

ImageURL returns the URL for the attached image (if present) or an empty string.

func (SearchTag) RelatedTags added in v0.7.0

func (searchTag SearchTag) RelatedTags() sliceof.String

RelatedTags returns a parsed slice of tags from the "Related" tag field.

func (*SearchTag) SetString added in v0.7.0

func (searchTag *SearchTag) SetString(name string, value string) bool

SetString implements the schema.StringSetter interface, and allows write access to many fields of a SearchTag object

func (SearchTag) StatusText added in v0.7.0

func (searchTag SearchTag) StatusText() string

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.
	RankAlt          int                          `json:"rankAlt"                bson:"rankAlt"`                // Alternate sort criteria
	StartTime        int64                        `json:"startTime"              bson:"startTime"`              // Unix timestamp of the date/time when an event is expected to start
	EndTime          int64                        `json:"endTime"                bson:"endTime"`                // Unix timestamp of the date/time when an event is expected to end
	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 streams 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
	IconURL          string                       `json:"iconUrl,omitempty"      bson:"iconUrl,omitempty"`      // URL of this document's icon/thumbnail image
	Context          string                       `json:"context,omitempty"      bson:"context,omitempty"`      // Context of this document (usually a URL)
	InReplyTo        string                       `json:"inReplyTo"              bson:"inReplyTo"`              // If this stream is a reply to another stream or web page, then this links to the original document.
	AttributedTo     PersonLink                   `json:"attributedTo,omitempty" bson:"attributedTo,omitempty"` // List of people who are attributed to this document
	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.
	Hashtags         sliceof.String               `json:"hashtags,omitempty"     bson:"hashtags,omitempty"`     // List of hashtags 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.
	Syndication      delta.Slice[string]          `json:"syndication,omitempty"  bson:"syndication,omitempty"`  // List of external services that this Stream has been syndicated to.
	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.
	IsFeatured       bool                         `json:"isFeatured"             bson:"isFeatured"`             // TRUE if this Stream is featured by its parent container.
	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) ActivityPubChildrenURL added in v0.7.0

func (stream Stream) ActivityPubChildrenURL() 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 *Stream) ActorLink() PersonLink

ActorLink returns a PersonLink object that represents this Stream as an ActivityPub "actor"

func (*Stream) AssignPermission

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

AssignPermissions assigns a role to a group

func (*Stream) CopyFrom added in v0.7.0

func (stream *Stream) CopyFrom(other Stream)

CopyFrom sets all values in this Stream to match the values in the provided Stream

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) GetBoolOK added in v0.7.0

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

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) GetWebhookData added in v0.7.0

func (stream Stream) GetWebhookData() mapof.Any

GetWebhookData returns the data for this Stream that will be sent to a webhook

func (*Stream) GrandparentID added in v0.7.0

func (stream *Stream) GrandparentID() primitive.ObjectID

GrandParentID returns the ID of the parent of the parent of this Stream (if it exists)

func (*Stream) GrandparentURL added in v0.7.0

func (stream *Stream) GrandparentURL() string

GrandparentURL returns the URL of the parent of the parent of this Stream (if it exists)

func (*Stream) HasGrandparent added in v0.7.0

func (stream *Stream) HasGrandparent() bool

HasGrandparent returns TRUE if this Stream has a GrandparentID

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 returns TRUE if this Stream is currently published

func (*Stream) ParentURL added in v0.7.0

func (stream *Stream) ParentURL() string

ParentURL returns the URL for the parent object

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) SetBool added in v0.7.0

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

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
}

StreamActor defines the settings for a Stream to be used as an Actor in social integrations

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
	IconURL        string             `json:"iconUrl,omitempty"      bson:"iconUrl,omitempty"`      // URL of the icon image for this document
	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
	UnPublishDate  int64              `json:"unpublishDate"          bson:"unpublishDate"`          // Date when this stream should be removed from public view
	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.
	IsFeatured     bool               `json:"isFeatured"             bson:"isFeatured"`             // If this Stream is "featured" then it will be displayed in a special location on the page.
	CreateDate     int64              `json:"createDate"             bson:"createDate"`             // Date when this stream was created
}

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) IsPublished added in v0.7.0

func (summary StreamSummary) IsPublished() bool

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 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)
	SocialRules        translate.Pipeline   `json:"socialRules"        bson:"socialRules"`        // List of rules to convert this Template into a social object
	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
	TagPaths           []string             `json:"tagPaths"           bson:"tagPaths"`           // List of paths to tags that are used in this template
	SearchOptions      templatemap.Map      `json:"search"             bson:"search"`             // Compiled templates that override default search result values
	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
	Datasets           DatasetMap           `json:"datasets"           bson:"-"`                  // Lookup codes defined by this template
	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) GetOEmbed added in v0.7.0

func (template *Template) GetOEmbed() *template.Template

GetOEmbed returns the OEmbed template for this Template If no OEmbed template is found, then nil is returned

func (*Template) HasOEmbed added in v0.7.0

func (template *Template) HasOEmbed() bool

HasOEmbed returns TRUE if this Template has an OEmbed 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) IsZero added in v0.7.0

func (template Template) IsZero() 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.
	DefaultInbox   string                  `json:"defaultInbox"   bson:"defaultInbox"`   // Default Inbox Template for Users created underneath this theme
	DefaultOutbox  string                  `json:"defaultOutbox"  bson:"defaultOutbox"`  // Default Outbox Template for Users created underneath this theme
	Form           form.Element            `json:"form"           bson:"form"`           // Form used to edit custom data
	Schema         schema.Schema           `json:"schema"         bson:"schema"`         // Schema used to validate custom data
	Data           mapof.String            `json:"data"           bson:"data"`           // Custom data for 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.
	MapIDs          mapof.String               `json:"mapIds"          bson:"mapIds"`               // Map of IDs for this user on other web services.
	GroupIDs        id.Slice                   `json:"groupIds"        bson:"groupIds"`             // Slice of IDs for the groups that this user belongs to.
	IconID          primitive.ObjectID         `json:"iconId"          bson:"iconId"`               // AttachmentID of this user's avatar/icon image.
	ImageID         primitive.ObjectID         `json:"imageId"         bson:"imageId"`              // AttachmentID of this user's banner 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.
	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.
	StateID         string                     `json:"stateId"         bson:"stateId"`              // State ID for this user
	InboxTemplate   string                     `json:"inboxTemplate"   bson:"inboxTemplate"`        // Template for the user's inbox
	OutboxTemplate  string                     `json:"outboxTemplate"  bson:"outboxTemplate"`       // Template for the user's outbox
	NoteTemplate    string                     `json:"noteTemplate"    bson:"noteTemplate"`         // Template for generically created notes
	Hashtags        sliceof.String             `json:"hashtags"        bson:"hashtags"`             // Slice of tags that can be used to categorize this user.
	Links           sliceof.Object[PersonLink] `json:"links"           bson:"links"`                // Slice of links to profiles on other web services.
	PasswordReset   PasswordReset              `json:"-"               bson:"passwordReset"`        // Most recent password reset information.
	Data            mapof.String               `json:"data"            bson:"data"`                 // Custom profile data that can be stored with this User.
	journal.Journal `json:"-" bson:",inline"`

	FollowerCount  int  `json:"followerCount"   bson:"followerCount"`  // Number of followers for this user
	FollowingCount int  `json:"followingCount"  bson:"followingCount"` // Number of actors that this user is following
	RuleCount      int  `json:"ruleCount"       bson:"ruleCount"`      // Number of rules (blocks) that this user has implemented
	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 visible
	IsIndexable    bool `json:"isIndexable"     bson:"isIndexable"`    // If TRUE, then this user's profile can be indexed by search engines.
}

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) ActivityPubBlockedURL

func (user *User) ActivityPubBlockedURL() string

func (*User) ActivityPubFollowersURL

func (user *User) ActivityPubFollowersURL() string

func (*User) ActivityPubFollowingURL

func (user *User) ActivityPubFollowingURL() string

func (*User) ActivityPubIconURL added in v0.7.0

func (user *User) ActivityPubIconURL() string

func (*User) ActivityPubImageURL added in v0.7.0

func (user *User) ActivityPubImageURL() 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) AddGroup added in v0.7.0

func (user *User) AddGroup(groupID primitive.ObjectID)

AddGroup adds a new group to this user's list of groups, avoiding duplicates

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) 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) 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) GetWebhookData added in v0.7.0

func (user User) GetWebhookData() mapof.Any

GetWebhookData returns the data for this User that will be sent to a webhook

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) RemoveGroup added in v0.7.0

func (user *User) RemoveGroup(groupID primitive.ObjectID)

RemoveGroup removes a group from this user's list of groups

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) SetState added in v0.7.0

func (user *User) SetState(stateID string)

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"`
	IconID        primitive.ObjectID `bson:"iconId"`
	DisplayName   string             `bson:"displayName"`
	EmailAddress  string             `bson:"emailAddress"`
	Username      string             `bson:"username"`
	ProfileURL    string             `bson:"profileUrl"`
	StatusMessage string             `bson:"statusMessage"`
	Hashtags      sliceof.String     `bson:"hashtags"`
}

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

func (UserSummary) IconURL added in v0.7.0

func (userSummary UserSummary) IconURL() string

type Webhook added in v0.7.0

type Webhook struct {
	WebhookID       primitive.ObjectID `json:"webhookId" bson:"_id"`
	Events          sliceof.String     `json:"events"    bson:"events"`
	Label           string             `json:"label"     bson:"label"`
	TargetURL       string             `json:"targetUrl" bson:"targetUrl"`
	journal.Journal `json:"-" bson:",inline"`
}

Webhook defines an outbound webhook that can be triggered by events in the system

func NewWebhook added in v0.7.0

func NewWebhook() Webhook

NewWebhook returns a fully initialized Webhook object

func (Webhook) Fields added in v0.7.0

func (userSummary Webhook) Fields() []string

func (*Webhook) GetPointer added in v0.7.0

func (webhook *Webhook) GetPointer(name string) (any, bool)

func (Webhook) GetStringOK added in v0.7.0

func (webhook Webhook) GetStringOK(name string) (string, bool)

func (Webhook) ID added in v0.7.0

func (webhook Webhook) ID() string

ID returns the unique identifier for this Webhook, and is required to implement the data.Object interface

func (*Webhook) SetString added in v0.7.0

func (webhook *Webhook) SetString(name string, value string) bool

type WebhookDataGetter added in v0.7.0

type WebhookDataGetter interface {
	GetWebhookData() mapof.Any
}

WebhookDataGetter wraps the GetWebhook() method, which lets an object return an arbitrary data structure to be sent as a webhook

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

Source Files

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