models

package
v0.0.0-...-7e4e87f Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

package models contains the database models for the m. Urgh, a package called models, I know, I know.

Index

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

func MaybeExcludeReblogs(r *http.Request) func(db *gorm.DB) *gorm.DB

MaybeExcludeReblogs returns a query that excludes reblogs if the request contains the exclude_reblogs parameter.

func MaybeExcludeReplies

func MaybeExcludeReplies(r *http.Request) func(db *gorm.DB) *gorm.DB

MaybeExcludeReplies returns a query that excludes replies if the request contains the exclude_replies parameter.

func MaybePinned

func MaybePinned(r *http.Request) func(db *gorm.DB) *gorm.DB

MaybePinned returns a query that only includes pinned statuses if the request contains the pinned parameter.

func PaginateActors

func PaginateActors(r *http.Request) func(db *gorm.DB) *gorm.DB

func PaginateConversation

func PaginateConversation(r *http.Request) func(db *gorm.DB) *gorm.DB

func PaginateRelationship

func PaginateRelationship(r *http.Request) func(db *gorm.DB) *gorm.DB

func PaginateStatuses

func PaginateStatuses(r *http.Request) func(db *gorm.DB) *gorm.DB

func PreloadActor

func PreloadActor(query *gorm.DB) *gorm.DB

PreloadActor preloads all of an Actor's relations and associations.

func PreloadReaction

func PreloadReaction(actor *Actor) func(query *gorm.DB) *gorm.DB

PreloadReaction preloads all of a Reaction's relations and associations.

func PreloadStatus

func PreloadStatus(query *gorm.DB) *gorm.DB

PreloadStatus preloads all of a Status' 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.

func (*Account) Domain

func (a *Account) Domain() string

func (*Account) Name

func (a *Account) Name() string

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 AccountListMember struct {
	AccountListID snowflake.ID `gorm:"primarykey;autoIncrement:false"`
	MemberID      snowflake.ID `gorm:"primarykey;autoIncrement:false"`
	Member        *Actor       `gorm:"constraint:OnDelete:CASCADE;"`
}

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 AccountRole struct {
	ID          uint32 `gorm:"primaryKey"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Name        string `gorm:"size:16;not null"`
	Color       string `gorm:"size:8;not null,default:''"`
	Position    int32
	Permissions uint32
	Highlighted bool
}

type Accounts

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

func NewAccounts

func NewAccounts(db *gorm.DB) *Accounts

func (*Accounts) AccountForActor

func (a *Accounts) AccountForActor(actor *Actor) (*Account, error)

func (*Accounts) Create

func (a *Accounts) Create(instance *Instance, name, email, password string) (*Account, error)

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:''"`
	SharedInboxURL string            `gorm:"size:255;not null;default:''"`
}

func (*Actor) Acct

func (a *Actor) Acct() string

func (*Actor) ActorType

func (a *Actor) ActorType() string

func (*Actor) AfterCreate

func (a *Actor) AfterCreate(tx *gorm.DB) error

func (*Actor) AfterSave

func (a *Actor) AfterSave(tx *gorm.DB) error

func (*Actor) AfterUpdate

func (a *Actor) AfterUpdate(tx *gorm.DB) error

func (*Actor) Inbox

func (a *Actor) Inbox() string

Inbox returns the actor's inbox URL, or shared inbox URL if applicable.

func (*Actor) IsBot

func (a *Actor) IsBot() bool

func (*Actor) IsGroup

func (a *Actor) IsGroup() bool

func (*Actor) IsLocal

func (a *Actor) IsLocal() bool

IsLocal indicates whether the actor is local to the instance.

func (*Actor) IsPerson

func (a *Actor) IsPerson() bool

func (*Actor) IsRemote

func (a *Actor) IsRemote() bool

IsRemote indicates whether the actor is not local to the instance.

func (*Actor) PublicKeyID

func (a *Actor) PublicKeyID() string

func (*Actor) URL

func (a *Actor) URL() string

type ActorAttribute

type ActorAttribute struct {
	ID      uint32       `gorm:"primarykey"`
	ActorID snowflake.ID `gorm:"index;not null"`
	Name    string       `gorm:"size:255;not null"`
	Value   string       `gorm:"type:text;not null"`
}

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 ActorType

type ActorType string

func (ActorType) GormDBDataType

func (ActorType) GormDBDataType(db *gorm.DB, field *schema.Field) string

type Actors

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

func NewActors

func NewActors(db *gorm.DB) *Actors

func (*Actors) FindByURI

func (a *Actors) FindByURI(uri string) (*Actor, error)

FindByURI returns an account by its URI if it exists locally.

func (*Actors) FindOrCreate

func (a *Actors) FindOrCreate(uri string, createFn func(context.Context, string) (*Actor, error)) (*Actor, error)

FindOrCreate finds an account by its URI, or creates it if it doesn't exist.

func (*Actors) Refresh

func (a *Actors) Refresh(actor *Actor) error

Refesh schedules a refresh of an actor's data.

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 Env

type Env struct {
	// DB is the database connection.
	DB     *gorm.DB
	Logger *slog.Logger
}

func (*Env) Log

func (e *Env) Log() *slog.Logger

type FocalPoint

type FocalPoint struct {
	X float64 `gorm:"not null;default:0"`
	Y float64 `gorm:"not null;default:0"`
}

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 InstanceRule struct {
	ID         uint32 `gorm:"primarykey"`
	InstanceID uint64
	Text       string
}

type Instances

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

func NewInstances

func NewInstances(db *gorm.DB) *Instances

func (*Instances) Create

func (i *Instances) Create(domain, title, description, adminEmail string) (*Instance, error)

Create creates a new instance, complete with an admin account.

type Peer

type Peer struct {
	Domain string `gorm:"primary_key;size:64"`
}

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

func (PushSubscriptionPolicy) GormDBDataType(db *gorm.DB, field *schema.Field) string

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.

func (*Reaction) AfterSave

func (r *Reaction) AfterSave(tx *gorm.DB) error

func (*Reaction) BeforeUpdate

func (r *Reaction) BeforeUpdate(tx *gorm.DB) error

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

func (ReactionRequestAction) GormDBDataType(db *gorm.DB, field *schema.Field) string

type Reactions

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

func NewReactions

func NewReactions(db *gorm.DB) *Reactions

func (*Reactions) Bookmark

func (r *Reactions) Bookmark(status *Status, actor *Actor) (*Reaction, error)

func (*Reactions) Favourite

func (r *Reactions) Favourite(status *Status, actor *Actor) (*Reaction, error)

func (*Reactions) Pin

func (r *Reactions) Pin(status *Status, actor *Actor) (*Reaction, error)

func (*Reactions) Reblog

func (r *Reactions) Reblog(status *Status, actor *Actor) (*Status, error)

Reblog creates a new status that is a reblog of the given status.

func (*Reactions) Unbookmark

func (r *Reactions) Unbookmark(status *Status, actor *Actor) (*Reaction, error)

func (*Reactions) Unfavourite

func (r *Reactions) Unfavourite(status *Status, actor *Actor) (*Reaction, error)

func (*Reactions) Unpin

func (r *Reactions) Unpin(status *Status, actor *Actor) (*Reaction, error)

func (*Reactions) Unreblog

func (r *Reactions) Unreblog(status *Status, actor *Actor) (*Status, error)

Unreblog removes the reblog of the given status with the given actor.

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

func (RelationshipRequestAction) GormDBDataType(db *gorm.DB, field *schema.Field) string

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.

func (*Status) AfterCreate

func (st *Status) AfterCreate(tx *gorm.DB) error

func (*Status) AfterUpdate

func (st *Status) AfterUpdate(tx *gorm.DB) error

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.

func (*StatusAttachment) AfterSave

func (s *StatusAttachment) AfterSave(tx *gorm.DB) error

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 StatusMention struct {
	StatusID snowflake.ID `gorm:"primarykey;autoIncrement:false"`
	ActorID  snowflake.ID `gorm:"primarykey;autoIncrement:false"`
	Actor    *Actor       `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // don't update actor on mention update
}

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 StatusPollOption struct {
	ID           uint32 `gorm:"primarykey;autoIncrement:true"`
	StatusPollID snowflake.ID
	Title        string `gorm:"size:255;not null"`
	Count        int    `gorm:"not null;default:0"`
}

type StatusTag

type StatusTag struct {
	StatusID snowflake.ID `gorm:"primarykey;autoIncrement:false"`
	TagID    uint32       `gorm:"primarykey;autoIncrement:false"`
	Tag      *Tag
}

type Statuses

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

func NewStatuses

func NewStatuses(db *gorm.DB) *Statuses

func (*Statuses) Create

func (s *Statuses) Create(actor *Actor, parent *Status, visibility Visibility, sensitive bool, spoilterText, language, note string) (*Status, error)

func (*Statuses) FindByID

func (s *Statuses) FindByID(id snowflake.ID) (*Status, error)

func (*Statuses) FindByURI

func (s *Statuses) FindByURI(uri string) (*Status, error)

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 Tag

type Tag struct {
	ID   uint32 `gorm:"primaryKey"`
	Name string `gorm:"size:64;uniqueIndex"`
}

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.

type TokenType

type TokenType string

func (TokenType) GormDBDataType

func (TokenType) GormDBDataType(db *gorm.DB, field *schema.Field) string

type Visibility

type Visibility string

func (Visibility) GormDBDataType

func (Visibility) GormDBDataType(db *gorm.DB, field *schema.Field) string

Jump to

Keyboard shortcuts

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