models

package
v0.0.0-...-25459cf Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostTypeStory    = "story"
	PostTypeArticle  = "article"
	PostTypeQuestion = "question"
	PostTypeVideo    = "video"
)
View Source
const (
	PostVisibilityAll = PostVisibilityLevel(iota)
	PostVisibilityFriends
	PostVisibilityFiltered
	PostVisibilitySelected
	PostVisibilityNone
)
View Source
const (
	PublisherTypePersonal = iota
	PublisherTypeOrganization
	PublisherTypeAnonymous
)
View Source
const (
	AttitudeNeutral = ReactionAttitude(iota)
	AttitudePositive
	AttitudeNegative
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	cruda.BaseModel

	Alias       string `json:"alias" gorm:"uniqueIndex" validate:"lowercase,alphanum"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Posts       []Post `json:"posts" gorm:"many2many:post_categories"`
}

type Poll

type Poll struct {
	cruda.BaseModel

	ExpiredAt *time.Time                      `json:"expired_at"`
	Options   datatypes.JSONSlice[PollOption] `json:"options"`
	AccountID uint                            `json:"account_id"`

	Metric PollMetric `json:"metric" gorm:"-"`
}

type PollAnswer

type PollAnswer struct {
	cruda.BaseModel

	Answer    string `json:"answer"`
	PollID    uint   `json:"poll_id"`
	AccountID uint   `json:"account_id"`
}

type PollMetric

type PollMetric struct {
	TotalAnswer         int64              `json:"total_answer"`
	ByOptions           map[string]int64   `json:"by_options"`
	ByOptionsPercentage map[string]float64 `json:"by_options_percentage"`
}

type PollOption

type PollOption struct {
	ID          string `json:"id"`
	Icon        string `json:"icon"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Post

type Post struct {
	cruda.BaseModel

	Type        string            `json:"type"`
	Body        datatypes.JSONMap `json:"body" gorm:"index:,type:gin"`
	Language    string            `json:"language"`
	Alias       *string           `json:"alias" gorm:"index"`
	AliasPrefix *string           `json:"alias_prefix" gorm:"index"`
	Tags        []Tag             `json:"tags" gorm:"many2many:post_tags"`
	Categories  []Category        `json:"categories" gorm:"many2many:post_categories"`
	Reactions   []Reaction        `json:"reactions"`
	Replies     []Post            `json:"replies" gorm:"foreignKey:ReplyID"`
	Flags       []PostFlag        `json:"flags" gorm:"foreignKey:PostID"`
	ReplyID     *uint             `json:"reply_id"`
	RepostID    *uint             `json:"repost_id"`
	ReplyTo     *Post             `json:"reply_to" gorm:"foreignKey:ReplyID"`
	RepostTo    *Post             `json:"repost_to" gorm:"foreignKey:RepostID"`

	VisibleUsers   datatypes.JSONSlice[uint] `json:"visible_users_list"`
	InvisibleUsers datatypes.JSONSlice[uint] `json:"invisible_users_list"`
	Visibility     PostVisibilityLevel       `json:"visibility"`

	EditedAt *time.Time `json:"edited_at"`
	PinnedAt *time.Time `json:"pinned_at"`
	LockedAt *time.Time `json:"locked_at"`

	IsCollapsed    bool       `json:"is_collapsed"`
	IsDraft        bool       `json:"is_draft"`
	PublishedAt    *time.Time `json:"published_at"`
	PublishedUntil *time.Time `json:"published_until"`

	TotalUpvote          int   `json:"total_upvote"`
	TotalDownvote        int   `json:"total_downvote"`
	TotalViews           int64 `json:"total_views"`
	TotalAggressiveViews int64 `json:"total_aggressive_views"`

	PollID *uint `json:"poll_id"`
	Poll   *Poll `json:"poll"`

	RealmID *uint        `json:"realm_id"`
	Realm   *authm.Realm `json:"realm" gorm:"-"`

	PublisherID uint      `json:"publisher_id"`
	Publisher   Publisher `json:"publisher"`

	Metric PostMetric `json:"metric" gorm:"-"`
}

type PostArticleBody

type PostArticleBody struct {
	Thumbnail   *string  `json:"thumbnail"`
	Title       string   `json:"title"`
	Description *string  `json:"description"`
	Content     string   `json:"content"`
	Attachments []string `json:"attachments"`
}

type PostFlag

type PostFlag struct {
	cruda.BaseModel

	PostID    uint `json:"post_id"`
	AccountID uint `json:"account_id"`
}

type PostInsight

type PostInsight struct {
	cruda.BaseModel

	Response string `json:"response"`
	Post     Post   `json:"post"`
	PostID   uint   `json:"post_id"`
}

type PostMetric

type PostMetric struct {
	ReplyCount    int64            `json:"reply_count"`
	ReactionCount int64            `json:"reaction_count"`
	ReactionList  map[string]int64 `json:"reaction_list,omitempty"`
}

type PostQuestionBody

type PostQuestionBody struct {
	PostStoryBody
	Answer *uint   `json:"answer"`
	Reward float64 `json:"reward"`
}

type PostStoryBody

type PostStoryBody struct {
	Thumbnail   *string  `json:"thumbnail"`
	Title       *string  `json:"title"`
	Content     string   `json:"content"`
	Location    *string  `json:"location"`
	Attachments []string `json:"attachments"`
}

type PostVideoBody

type PostVideoBody struct {
	Thumbnail   *string           `json:"thumbnail"`
	Title       string            `json:"title"`
	Description *string           `json:"description"`
	Location    *string           `json:"location"`
	Video       string            `json:"video"`
	Renderer    *string           `json:"renderer"`
	IsLive      bool              `json:"is_live"`
	IsLiveEnded bool              `json:"is_live_ended"`
	Subtitles   map[string]string `json:"subtitles"`
}

type PostView

type PostView struct {
	AccountID uint      `json:"account_id" gorm:"primaryKey"`
	PostID    uint      `json:"post_id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type PostVisibilityLevel

type PostVisibilityLevel = int8

type Publisher

type Publisher struct {
	cruda.BaseModel

	Type int `json:"type"`

	Name        string `json:"name" gorm:"uniqueIndex"`
	Nick        string `json:"nick"`
	Description string `json:"description"`
	Avatar      string `json:"avatar"`
	Banner      string `json:"banner"`

	Posts []Post `json:"posts"`

	TotalUpvote   int `json:"total_upvote"`
	TotalDownvote int `json:"total_downvote"`

	RealmID   *uint `json:"realm_id"`
	AccountID *uint `json:"account_id"`

	Account models.Account `gorm:"-" json:"account"`
	Realm   models.Realm   `gorm:"-" json:"realm"`
}

type Reaction

type Reaction struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Symbol   string           `json:"symbol"`
	Attitude ReactionAttitude `json:"attitude"`

	PostID    uint `json:"post_id"`
	AccountID uint `json:"account_id"`
}

type ReactionAttitude

type ReactionAttitude = uint8

type Subscription

type Subscription struct {
	cruda.BaseModel

	FollowerID uint  `json:"follower_id"`
	AccountID  *uint `json:"account_id,omitempty"`
	TagID      *uint `json:"tag_id,omitempty"`
	CategoryID *uint `json:"category_id,omitempty"`
}

type Tag

type Tag struct {
	cruda.BaseModel

	Alias       string `json:"alias" gorm:"uniqueIndex" validate:"lowercase"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Posts       []Post `json:"posts" gorm:"many2many:post_tags"`
}

Jump to

Keyboard shortcuts

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