Documentation ¶
Overview ¶
package models contains the database models for the m. Urgh, a package called models, I know, I know.
Index ¶
- func AllTables() []interface{}
- func MaybeExcludeReblogs(r *http.Request) func(db *gorm.DB) *gorm.DB
- func MaybeExcludeReplies(r *http.Request) func(db *gorm.DB) *gorm.DB
- func MaybePinned(r *http.Request) func(db *gorm.DB) *gorm.DB
- func PaginateActors(r *http.Request) func(db *gorm.DB) *gorm.DB
- func PaginateConversation(r *http.Request) func(db *gorm.DB) *gorm.DB
- func PaginateRelationship(r *http.Request) func(db *gorm.DB) *gorm.DB
- func PaginateStatuses(r *http.Request) func(db *gorm.DB) *gorm.DB
- func PreloadActor(query *gorm.DB) *gorm.DB
- func PreloadReaction(actor *Actor) func(query *gorm.DB) *gorm.DB
- func PreloadStatus(query *gorm.DB) *gorm.DB
- type Account
- type AccountList
- type AccountListMember
- type AccountMarker
- type AccountPreferences
- type AccountRole
- type Accounts
- type ActivitypubOutboxRequest
- type ActivitypubRefresh
- type Actor
- func (a *Actor) Acct() string
- func (a *Actor) ActorType() string
- func (a *Actor) AfterCreate(tx *gorm.DB) error
- func (a *Actor) AfterSave(tx *gorm.DB) error
- func (a *Actor) AfterUpdate(tx *gorm.DB) error
- func (a *Actor) Inbox() string
- func (a *Actor) IsBot() bool
- func (a *Actor) IsGroup() bool
- func (a *Actor) IsLocal() bool
- func (a *Actor) IsPerson() bool
- func (a *Actor) IsRemote() bool
- func (a *Actor) PublicKeyID() string
- func (a *Actor) URL() string
- type ActorAttribute
- type ActorRefreshRequest
- type ActorType
- type Actors
- type Application
- type Attachment
- type Conversation
- type Env
- type FocalPoint
- type Instance
- type InstanceRule
- type Instances
- type Peer
- type PushSubscription
- type PushSubscriptionPolicy
- type Reaction
- type ReactionRequest
- type ReactionRequestAction
- type Reactions
- func (r *Reactions) Bookmark(status *Status, actor *Actor) (*Reaction, error)
- func (r *Reactions) Favourite(status *Status, actor *Actor) (*Reaction, error)
- func (r *Reactions) Pin(status *Status, actor *Actor) (*Reaction, error)
- func (r *Reactions) Reblog(status *Status, actor *Actor) (*Status, error)
- func (r *Reactions) Unbookmark(status *Status, actor *Actor) (*Reaction, error)
- func (r *Reactions) Unfavourite(status *Status, actor *Actor) (*Reaction, error)
- func (r *Reactions) Unpin(status *Status, actor *Actor) (*Reaction, error)
- func (r *Reactions) Unreblog(status *Status, actor *Actor) (*Status, error)
- type Relationship
- type RelationshipRequest
- type RelationshipRequestAction
- type Relationships
- func (r *Relationships) Block(actor, target *Actor) (*Relationship, error)
- func (r *Relationships) Follow(actor, target *Actor) (*Relationship, error)
- func (r *Relationships) Mute(actor, target *Actor) (*Relationship, error)
- func (r *Relationships) Unblock(actor, target *Actor) (*Relationship, error)
- func (r *Relationships) Unfollow(actor, target *Actor) (*Relationship, error)
- func (r *Relationships) Unmute(actor, target *Actor) (*Relationship, error)
- type Request
- type Status
- type StatusAttachment
- type StatusAttachmentRequest
- type StatusMention
- type StatusPoll
- type StatusPollOption
- type StatusTag
- type Statuses
- func (s *Statuses) Create(actor *Actor, parent *Status, visibility Visibility, sensitive bool, ...) (*Status, error)
- func (s *Statuses) FindByID(id snowflake.ID) (*Status, error)
- func (s *Statuses) FindByURI(uri string) (*Status, error)
- func (s *Statuses) FindOrCreate(uri string, createFn func(string) (*Status, error)) (*Status, error)
- type Tag
- type Token
- type TokenType
- type Visibility
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllTables ¶
func AllTables() []interface{}
AllTables returns a slice of all tables in the database.
func MaybeExcludeReblogs ¶
MaybeExcludeReblogs returns a query that excludes reblogs if the request contains the exclude_reblogs parameter.
func MaybeExcludeReplies ¶
MaybeExcludeReplies returns a query that excludes replies if the request contains the exclude_replies parameter.
func MaybePinned ¶
MaybePinned returns a query that only includes pinned statuses if the request contains the pinned parameter.
func PreloadActor ¶
PreloadActor preloads all of an Actor's relations and associations.
func PreloadReaction ¶
PreloadReaction preloads all of a Reaction's relations and associations.
Types ¶
type Account ¶
type Account struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` UpdatedAt time.Time InstanceID snowflake.ID Instance *Instance `gorm:"<-:create;"` ActorID snowflake.ID Actor *Actor `gorm:"<-:create;"` Lists []AccountList `gorm:"constraint:OnDelete:CASCADE;"` Markers []AccountMarker `gorm:"constraint:OnDelete:CASCADE;"` Email string `gorm:"size:64;not null"` EncryptedPassword []byte `gorm:"size:60;not null"` PrivateKey []byte `gorm:"not null"` RoleID uint32 Role *AccountRole }
An Account is a user account on an Instance. An Account belongs to an Actor. An Account belongs to an Instance.
type AccountList ¶
type AccountList struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` AccountID snowflake.ID `gorm:"not null;"` Title string `gorm:"size:64"` RepliesPolicy string `gorm:"enum('public','followers','none');not null;default:'public'"` Members []AccountListMember `gorm:"constraint:OnDelete:CASCADE;"` }
type AccountListMember ¶
type AccountMarker ¶
type AccountMarker struct { ID uint32 `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time AccountID snowflake.ID `gorm:"not null;uniqueIndex:idx_account_name;index"` Name string `gorm:"enum('home','notifications');not null;uniqueIndex:idx_account_name"` Version int32 `gorm:"not null;"` LastReadID snowflake.ID `gorm:"not null;"` }
type AccountPreferences ¶
type AccountPreferences struct { AccountID snowflake.ID `gorm:"primarykey;autoIncrement:false"` PostingDefaultVisibility string `gorm:"enum('public', 'unlisted', 'private', 'direct');not null;default:'public'"` PostingDefaultSensitive bool `gorm:"not null;default:false"` PostingDefaultLanguage string `gorm:"size:8;"` ReadingExpandMedia string `gorm:"enum('default','show_all','hide_all');not null;default:'default'"` ReadingExpandSpoilers bool `gorm:"not null;default:false"` }
type AccountRole ¶
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
func NewAccounts ¶
func (*Accounts) AccountForActor ¶
type ActivitypubOutboxRequest ¶
type ActivitypubOutboxRequest struct { Request // StatusID is the ID of the status to send. StatusID snowflake.ID `gorm:"not null"` Status *Status `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // ActorID is the ID of the remote actor to send the status to. ActorID snowflake.ID `gorm:"not null"` Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` }
ActivitypubOutboxRequest is a record of a request to send a status to an actor on a remote server.
type ActivitypubRefresh ¶
type ActivitypubRefresh struct { Request // URI is the URI to refresh. URI string `gorm:"size:255;not null;uniqueIndex"` // DependsOn is the URI that this URI depends on. // For example if URI is a reply, DependsOn is the URI of the status being replied to. // If URI is a status, DependsOn is the URI of the actor. DependsOn string `gorm:"size:255"` }
ActivitypubRefresh is a record of a request to refresh a URI.
type Actor ¶
type Actor struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` UpdatedAt time.Time `gorm:"autoUpdateTime:false"` Type ActorType `gorm:"default:'Person';not null"` URI string `gorm:"uniqueIndex;size:128;not null"` Name string `gorm:"size:64;uniqueIndex:idx_actor_name_domain;not null"` Domain string `gorm:"size:64;uniqueIndex:idx_actor_name_domain;not null"` DisplayName string `gorm:"size:128;not null"` Locked bool `gorm:"default:false;not null"` Note string `gorm:"type:text"` // max 2^16 FollowersCount int32 `gorm:"default:0;not null"` FollowingCount int32 `gorm:"default:0;not null"` StatusesCount int32 `gorm:"default:0;not null"` LastStatusAt time.Time Avatar string `gorm:"size:255"` Header string `gorm:"size:255"` PublicKey []byte `gorm:"size:16384;type:blob;not null"` Attributes []*ActorAttribute `gorm:"constraint:OnDelete:CASCADE;"` InboxURL string `gorm:"size:255;not null;default:''"` OutboxURL string `gorm:"size:255;not null;default:''"` }
func (*Actor) PublicKeyID ¶
type ActorAttribute ¶
type ActorRefreshRequest ¶
type ActorRefreshRequest struct { Request // ActorID is the ID of the actor to refresh. ActorID snowflake.ID `gorm:"uniqueIndex;not null;"` // Actor is the actor to refresh. Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` }
ActorRefreshRequest is a request to refresh an actor's data.
type Actors ¶
type Actors struct {
// contains filtered or unexported fields
}
type Application ¶
type Application struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` InstanceID snowflake.ID Instance *Instance `gorm:"constraint:OnDelete:CASCADE;<-:false;"` Name string `gorm:"size:255;not null"` Website string `gorm:"size:255"` RedirectURI string `gorm:"size:255;not null"` ClientID string `gorm:"size:255;not null"` ClientSecret string `gorm:"size:255;not null"` VapidKey string `gorm:"size:255;not null"` Scopes string `gorm:"size:255;not null;default:''"` }
An Application is a registered client application. An Application belongs to an Instance.
type Attachment ¶
type Attachment struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` MediaType string `gorm:"size:64;not null"` URL string `gorm:"size:255;not null"` Name string `gorm:"not null"` Blurhash string `gorm:"size:36;not null"` Width int `gorm:"not null"` Height int `gorm:"not null"` FocalPoint FocalPoint `gorm:"embedded;embeddedPrefix:focal_point_"` }
func (*Attachment) Extension ¶
func (att *Attachment) Extension() string
Extension returns the file extension of the attachment. This is used to generate the filename of the attachment which most IOS clients expect.
func (*Attachment) ToType ¶
func (att *Attachment) ToType() string
ToType returns the Mastodon type of the attachment, image, video, audio or unknown.
type Conversation ¶
type Conversation struct { ID uint32 `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time Visibility Visibility `gorm:"not null;check <> ''"` }
A Conversation is a collection of related statuses. It is a way to group together statuses that are replies to each other, or that are part of the same thread of conversation. Conversations are not necessarily public, and may be limited to a set of participants.
type FocalPoint ¶
type Instance ¶
type Instance struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` UpdatedAt time.Time Domain string `gorm:"size:64;uniqueIndex"` AdminID *snowflake.ID Admin *Account `gorm:"constraint:OnDelete:CASCADE;<-:create;"` // the admin account for this instance SourceURL string Title string `gorm:"size:64"` ShortDescription string Description string Thumbnail string `gorm:"size:64"` AccountsCount int `gorm:"default:0;not null"` StatusesCount int `gorm:"default:0;not null"` DomainsCount int32 `gorm:"default:0;not null"` Rules []InstanceRule `gorm:"constraint:OnDelete:CASCADE;"` }
An Instance is an ActivityPub domain managed by this server. An Instance has many InstanceRules. An Instance has one Admin Account.
type InstanceRule ¶
type Instances ¶
type Instances struct {
// contains filtered or unexported fields
}
func NewInstances ¶
type PushSubscription ¶
type PushSubscription struct { ID uint32 `gorm:"primaryKey"` AccountID snowflake.ID Account *Account `gorm:"constraint:OnDelete:CASCADE;<-:false;"` Endpoint string `gorm:"not null"` Mention bool Status bool Reblog bool Follow bool FollowRequest bool Favourite bool Poll bool Update bool Policy PushSubscriptionPolicy `gorm:"not null;default:'all'"` }
type PushSubscriptionPolicy ¶
type PushSubscriptionPolicy string
func (PushSubscriptionPolicy) GormDBDataType ¶
type Reaction ¶
type Reaction struct { StatusID snowflake.ID `gorm:"primarykey;autoIncrement:false"` Status *Status `gorm:"constraint:OnDelete:CASCADE;<-:false"` ActorID snowflake.ID `gorm:"primarykey;autoIncrement:false"` Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false"` Favourited bool `gorm:"not null;default:false"` Reblogged bool `gorm:"not null;default:false"` Muted bool `gorm:"not null;default:false"` Bookmarked bool `gorm:"not null;default:false"` Pinned bool `gorm:"not null;default:false"` }
Reaction represents an an actors reaction to a status.
type ReactionRequest ¶
type ReactionRequest struct { Request // ActorID is the ID of the actor that is requesting the reaction change. ActorID snowflake.ID `gorm:"uniqueIndex:uidx_reaction_requests_actor_id_target_id;not null;"` // Actor is the actor that is requesting the reaction change. Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false"` TargetID snowflake.ID `gorm:"uniqueIndex:uidx_reaction_requests_actor_id_target_id;not null;"` // Target is the status that is being reacted to. Target *Status `gorm:"constraint:OnDelete:CASCADE;<-:false"` // Action is the action to perform, either follow or unfollow. Action ReactionRequestAction `gorm:"not null"` }
A ReactionRequest is a request to update the reaction to a status. ReactionRequests are created by hooks on the Reaction model, and are processed by the ReactionRequestProcessor in the background.
type ReactionRequestAction ¶
type ReactionRequestAction string
func (ReactionRequestAction) GormDBDataType ¶
type Reactions ¶
type Reactions struct {
// contains filtered or unexported fields
}
func NewReactions ¶
func (*Reactions) Unbookmark ¶
func (*Reactions) Unfavourite ¶
type Relationship ¶
type Relationship struct { ActorID snowflake.ID `gorm:"primarykey;autoIncrement:false"` Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` TargetID snowflake.ID `gorm:"primarykey;autoIncrement:false"` Target *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` Muting bool `gorm:"not null;default:false"` Blocking bool `gorm:"not null;default:false"` BlockedBy bool `gorm:"not null;default:false"` Following bool `gorm:"not null;default:false"` FollowedBy bool `gorm:"not null;default:false"` Note string `gorm:"type:text"` }
func (*Relationship) AfterUpdate ¶
func (r *Relationship) AfterUpdate(tx *gorm.DB) error
AfterUpdate updates the followers and following counts for the actor and target.
func (*Relationship) BeforeUpdate ¶
func (r *Relationship) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate creates a relationship request between the actor and target.
type RelationshipRequest ¶
type RelationshipRequest struct { Request // ActorID is the ID of the actor that is requesting the relationship change. ActorID snowflake.ID `gorm:"uniqueIndex:uidx_relationship_requests_actor_id_target_id;not null;"` // Actor is the actor that is requesting the relationship change. Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` TargetID snowflake.ID `gorm:"uniqueIndex:uidx_relationship_requests_actor_id_target_id;not null;"` // Target is the actor that is being followed or unfollowed. Target *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // Action is the action to perform, either follow or unfollow. Action RelationshipRequestAction `gorm:"not null"` }
A RelationshipRequest records a request to follow or unfollow an actor. RelationshipRequests are created by hooks on the Relationship model, and are processed by the RelationshipRequestProcessor in the background.
type RelationshipRequestAction ¶
type RelationshipRequestAction string
func (RelationshipRequestAction) GormDBDataType ¶
type Relationships ¶
type Relationships struct {
// contains filtered or unexported fields
}
func NewRelationships ¶
func NewRelationships(db *gorm.DB) *Relationships
func (*Relationships) Block ¶
func (r *Relationships) Block(actor, target *Actor) (*Relationship, error)
Block blocks the target from the actor.
func (*Relationships) Follow ¶
func (r *Relationships) Follow(actor, target *Actor) (*Relationship, error)
Follow establishes a follow relationship between actor and the target.
func (*Relationships) Mute ¶
func (r *Relationships) Mute(actor, target *Actor) (*Relationship, error)
Mute mutes the target from the actor.
func (*Relationships) Unblock ¶
func (r *Relationships) Unblock(actor, target *Actor) (*Relationship, error)
Unblock removes a block relationship between actor and the target.
func (*Relationships) Unfollow ¶
func (r *Relationships) Unfollow(actor, target *Actor) (*Relationship, error)
Unfollow removes a follow relationship between actor and the target.
func (*Relationships) Unmute ¶
func (r *Relationships) Unmute(actor, target *Actor) (*Relationship, error)
Unmute removes a mute relationship between actor and the target.
type Request ¶
type Request struct { ID uint32 `gorm:"primarykey;"` // CreatedAt is the time the request was created. CreatedAt time.Time // UpdatedAt is the time the request was last updated. UpdatedAt time.Time // Attempts is the number of times the request has been attempted. Attempts uint32 `gorm:"not null;default:0"` // LastAttempt is the time the request was last attempted. LastAttempt time.Time // LastResult is the result of the last attempt if it failed. LastResult string `gorm:"type:text;"` }
type Status ¶
type Status struct { snowflake.ID `gorm:"primarykey;autoIncrement:false"` UpdatedAt time.Time `gorm:"autoUpdateTime:false"` ActorID snowflake.ID Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // don't update actor on status update ConversationID uint32 Conversation *Conversation `gorm:"constraint:OnDelete:CASCADE;"` InReplyToID *snowflake.ID InReplyTo *Status `gorm:"constraint:OnDelete:SET NULL;<-:false;"` // don't update in_reply_to on status update InReplyToActorID *snowflake.ID Sensitive bool `gorm:"not null;default:false"` SpoilerText string `gorm:"size:128"` Visibility Visibility `gorm:"not null"` Language string `gorm:"size:2"` Note string `gorm:"type:text"` URI string `gorm:"uniqueIndex;size:128"` RepliesCount int `gorm:"not null;default:0"` ReblogsCount int `gorm:"not null;default:0"` FavouritesCount int `gorm:"not null;default:0"` ReblogID *snowflake.ID Reblog *Status `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // don't update reblog on status update Reaction *Reaction `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // don't update reaction on status update Attachments []*StatusAttachment `gorm:"constraint:OnDelete:CASCADE;"` Mentions []StatusMention `gorm:"constraint:OnDelete:CASCADE;"` Tags []StatusTag `gorm:"constraint:OnDelete:CASCADE;"` Poll *StatusPoll `gorm:"constraint:OnDelete:CASCADE;"` }
A Status is a single message posted by a user. It may be a reply to another status, or a new thread of conversation. A Status belongs to a single Account, and is part of a single Conversation.
type StatusAttachment ¶
type StatusAttachment struct { Attachment StatusID snowflake.ID `gorm:"not null"` }
A StatusAttachment is an attachment to a Status. A Status has many StatusAttachments.
type StatusAttachmentRequest ¶
type StatusAttachmentRequest struct { ID uint32 `gorm:"primarykey;"` // CreatedAt is the time the request was created. CreatedAt time.Time // UpdatedAt is the time the request was last updated. UpdatedAt time.Time // StatusAttachmentID is the ID of the StatusAttachment that the request is for. StatusAttachmentID snowflake.ID `gorm:"uniqueIndex;not null;"` // StatusAttachment is the StatusAttachment that the request is for. StatusAttachment *StatusAttachment `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // Attempts is the number of times the request has been attempted. Attempts uint32 `gorm:"not null;default:0"` // LastAttempt is the time the request was last attempted. LastAttempt time.Time // LastResult is the result of the last attempt if it failed. LastResult string `gorm:"size:255;not null;default:''"` }
A StatusAttachmentRequest records a request fetch a remote attachment. StatusAttachmentRequest are created by hooks on the StatusAttachment model, and are processed by the StatusAttachmentRequestProcessor in the background.
type StatusMention ¶
type StatusPoll ¶
type StatusPoll struct { StatusID snowflake.ID `gorm:"primarykey;autoIncrement:false"` ExpiresAt time.Time Multiple bool VotesCount int `gorm:"not null;default:0"` Options []StatusPollOption `gorm:"constraint:OnDelete:CASCADE;"` }
func (*StatusPoll) AfterCreate ¶
func (st *StatusPoll) AfterCreate(tx *gorm.DB) error
type StatusPollOption ¶
type Statuses ¶
type Statuses struct {
// contains filtered or unexported fields
}
func NewStatuses ¶
func (*Statuses) FindOrCreate ¶
func (s *Statuses) FindOrCreate(uri string, createFn func(string) (*Status, error)) (*Status, error)
FindOrCreate searches for a status by its URI. If the status is not found, it calls the given function to create a new status, stores that status in the database and returns it.
type Token ¶
type Token struct { AccessToken string `gorm:"size:64;primaryKey;autoIncrement:false"` CreatedAt time.Time AccountID *snowflake.ID Account *Account `gorm:"constraint:OnDelete:CASCADE;<-:false;"` ApplicationID snowflake.ID Application *Application `gorm:"constraint:OnDelete:CASCADE;<-:false;"` TokenType `gorm:"not null"` Scope string `gorm:"size:64;not null"` AuthorizationCode string `gorm:"size:64;not null"` }
A Token is an access token for an Application. A Token belongs to an Account. A Token belongs to an Application.