models

package
v0.0.0-...-54d5358 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: BSD-3-Clause Imports: 19 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 PreloadAccount

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

PreloadAccount preloads all of an Account's relations and associations.

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 PreloadRelationshipTarget

func PreloadRelationshipTarget(db *gorm.DB) *gorm.DB

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

func (*Account) PrivKey

func (a *Account) PrivKey() (*rsa.PrivateKey, error)

func (*Account) PublicKey

func (a *Account) PublicKey() (*rsa.PublicKey, error)

func (*Account) PublicKeyID

func (a *Account) PublicKeyID() 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 {
	ObjectID       snowflake.ID `gorm:"primarykey;autoIncrement:false"`
	Object         *ActorObject `gorm:"constraint:OnDelete:CASCADE;<-:false"`
	UpdatedAt      time.Time    `gorm:"autoUpdateTime:false"`
	Type           ActorType    `gorm:"default:'Person';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"`
	FollowersCount int32        `gorm:"default:0;not null"`
	FollowingCount int32        `gorm:"default:0;not null"`
	StatusesCount  int32        `gorm:"default:0;not null"`
	LastStatusAt   time.Time
}

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

func (a *Actor) Attributes() []ActorAttachment

func (*Actor) Avatar

func (a *Actor) Avatar() string

func (*Actor) DisplayName

func (a *Actor) DisplayName() string

func (*Actor) Header

func (a *Actor) Header() string

func (*Actor) Inbox

func (a *Actor) Inbox() string

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

func (*Actor) InboxURL

func (a *Actor) InboxURL() string

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

func (a *Actor) Locked() bool

func (*Actor) Note

func (a *Actor) Note() string

func (*Actor) OutboxURL

func (a *Actor) OutboxURL() string

func (*Actor) PublicKey

func (a *Actor) PublicKey() []byte

func (*Actor) PublicKeyID

func (a *Actor) PublicKeyID() string

func (*Actor) SharedInboxURL

func (a *Actor) SharedInboxURL() string

func (*Actor) URI

func (a *Actor) URI() string

func (*Actor) URL

func (a *Actor) URL() string

type ActorAttachment

type ActorAttachment struct {
	Type  string `json:"type"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

type ActorObject

type ActorObject struct {
	ID         snowflake.ID
	Type       string
	URI        string
	Properties struct {
		Type string `json:"type"`
		// The Actor's unique global identifier.
		ID                string `json:"id"`
		Inbox             string `json:"inbox"`
		Outbox            string `json:"outbox"`
		PreferredUsername string `json:"preferredUsername"`
		Name              string `json:"name"`
		Summary           string `json:"summary"`
		Icon              struct {
			Type      string `json:"type"`
			MediaType string `json:"mediaType"`
			URL       string `json:"url"`
		} `json:"icon"`
		Image struct {
			Type      string `json:"type"`
			MediaType string `json:"mediaType"`
			URL       string `json:"url"`
		} `json:"image"`
		Endpoints struct {
			SharedInbox string `json:"sharedInbox"`
		} `json:"endpoints"`
		ManuallyApprovesFollowers bool `json:"manuallyApprovesFollowers"`
		PublicKey                 struct {
			ID           string `json:"id"`
			Owner        string `json:"owner"`
			PublicKeyPem string `json:"publicKeyPem"`
		} `json:"publicKey"`
		Attachments []ActorAttachment `json:"attachment"`
	} `gorm:"serializer:json;not null"`
}

func (ActorObject) TableName

func (ActorObject) TableName() string

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

func (a *Actors) Find(name, domain string) (*Actor, error)

Find finds an account by its name and domain.

func (*Actors) FindByURI

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

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

func (*Actors) FindOrCreateByURI

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

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 AttachmentFocalPoint

type AttachmentFocalPoint []float64

func (*AttachmentFocalPoint) UnmarshalJSON

func (fp *AttachmentFocalPoint) UnmarshalJSON(b []byte) error

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.

func (*Instances) FindByDomain

func (i *Instances) FindByDomain(domain string) (*Instance, error)

FindByDomain finds an instance by domain.

type Object

type Object struct {
	ID         snowflake.ID   `gorm:"primarykey;autoIncrement:false"`
	Type       string         `gorm:"type:varchar(16);not null"`
	URI        string         `gorm:"type:varchar(255);not null;uniqueIndex"`
	Properties map[string]any `gorm:"serializer:json;not null"`
}

Object represents an ActivityPub object.

func (*Object) AfterSave

func (o *Object) AfterSave(tx *gorm.DB) error

func (*Object) BeforeSave

func (o *Object) BeforeSave(tx *gorm.DB) error

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 {
	ObjectID         snowflake.ID  `gorm:"primarykey;autoIncrement:false"`
	Object           *StatusObject `gorm:"constraint:OnDelete:CASCADE;<-: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
	Visibility       Visibility `gorm:"not null"`
	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
}

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

func (*Status) Attachments

func (st *Status) Attachments() []*Attachment

func (*Status) Language

func (st *Status) Language() string

func (*Status) Note

func (st *Status) Note() string

func (*Status) Sensitive

func (st *Status) Sensitive() bool

func (*Status) SpoilerText

func (st *Status) SpoilerText() string

func (*Status) Tag

func (st *Status) Tag() []StatusTag

func (*Status) URI

func (st *Status) URI() string

type StatusAttachment

type StatusAttachment struct {
	Type       string               `json:"type"`
	MediaType  string               `json:"mediaType"`
	URL        string               `json:"url"`
	Name       string               `json:"name"`
	Width      int                  `json:"width"`
	Height     int                  `json:"height"`
	Blurhash   string               `json:"blurhash"`
	FocalPoint AttachmentFocalPoint `json:"focalPoint"`
}

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 StatusObject

type StatusObject struct {
	ID         snowflake.ID
	Type       string
	URI        string
	Properties struct {
		Type string `json:"type"`
		// The Actor's unique global identifier.
		ID         string             `json:"id"`
		Content    string             `json:"content"`
		Sensitive  bool               `json:"sensitive"` // as:sensitive
		Summary    string             `json:"summary"`
		Attachment []StatusAttachment `json:"attachment"`
		Tag        StatusTags         `json:"tag"`
	} `gorm:"serializer:json;not null"`
}

func (StatusObject) TableName

func (StatusObject) TableName() string

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 {
	Type string `json:"type"`
	Name string `json:"name"`
	HRef string `json:"href"`
}

type StatusTags

type StatusTags []StatusTag

func (*StatusTags) UnmarshalJSON

func (st *StatusTags) UnmarshalJSON(b []byte) error

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

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

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