2024-02-02 15:42:42 +00:00
|
|
|
package models
|
|
|
|
|
2024-03-02 17:23:11 +00:00
|
|
|
import (
|
|
|
|
"time"
|
2024-02-02 15:42:42 +00:00
|
|
|
|
2024-09-11 15:42:46 +00:00
|
|
|
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
|
2024-07-03 14:16:23 +00:00
|
|
|
"gorm.io/datatypes"
|
|
|
|
)
|
2024-03-02 17:23:11 +00:00
|
|
|
|
2024-07-21 17:19:23 +00:00
|
|
|
const (
|
|
|
|
PostTypeStory = "story"
|
|
|
|
PostTypeArticle = "article"
|
|
|
|
)
|
|
|
|
|
2024-07-27 17:49:16 +00:00
|
|
|
type PostVisibilityLevel = int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
PostVisibilityAll = PostVisibilityLevel(iota)
|
|
|
|
PostVisibilityFriends
|
|
|
|
PostVisibilityFiltered
|
|
|
|
PostVisibilitySelected
|
|
|
|
PostVisibilityNone
|
|
|
|
)
|
|
|
|
|
2024-05-15 11:45:49 +00:00
|
|
|
type Post struct {
|
2024-09-11 15:42:46 +00:00
|
|
|
hyper.BaseModel
|
2024-02-02 15:42:42 +00:00
|
|
|
|
2024-07-21 17:19:23 +00:00
|
|
|
Type string `json:"type"`
|
2024-07-21 16:49:36 +00:00
|
|
|
Body datatypes.JSONMap `json:"body"`
|
|
|
|
Language string `json:"language"`
|
2024-08-17 07:19:59 +00:00
|
|
|
Alias *string `json:"alias"`
|
2024-08-17 07:40:07 +00:00
|
|
|
AreaAlias *string `json:"area_alias"`
|
2024-07-21 16:49:36 +00:00
|
|
|
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"`
|
|
|
|
ReplyID *uint `json:"reply_id"`
|
|
|
|
RepostID *uint `json:"repost_id"`
|
|
|
|
RealmID *uint `json:"realm_id"`
|
|
|
|
ReplyTo *Post `json:"reply_to" gorm:"foreignKey:ReplyID"`
|
|
|
|
RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"`
|
|
|
|
Realm *Realm `json:"realm"`
|
2024-05-15 11:45:49 +00:00
|
|
|
|
2024-07-29 15:07:12 +00:00
|
|
|
VisibleUsers datatypes.JSONSlice[uint] `json:"visible_users_list"`
|
|
|
|
InvisibleUsers datatypes.JSONSlice[uint] `json:"invisible_users_list"`
|
2024-07-27 17:49:16 +00:00
|
|
|
Visibility PostVisibilityLevel `json:"visibility"`
|
|
|
|
|
2024-07-27 15:10:07 +00:00
|
|
|
EditedAt *time.Time `json:"edited_at"`
|
2024-07-25 14:58:47 +00:00
|
|
|
PinnedAt *time.Time `json:"pinned_at"`
|
2024-07-27 17:49:16 +00:00
|
|
|
LockedAt *time.Time `json:"locked_at"`
|
2024-07-25 14:58:47 +00:00
|
|
|
|
2024-07-21 17:44:04 +00:00
|
|
|
IsDraft bool `json:"is_draft"`
|
|
|
|
PublishedAt *time.Time `json:"published_at"`
|
|
|
|
PublishedUntil *time.Time `json:"published_until"`
|
2024-03-02 17:23:11 +00:00
|
|
|
|
2024-07-26 13:09:53 +00:00
|
|
|
TotalUpvote int `json:"total_upvote"`
|
|
|
|
TotalDownvote int `json:"total_downvote"`
|
|
|
|
|
2024-03-02 17:23:11 +00:00
|
|
|
AuthorID uint `json:"author_id"`
|
|
|
|
Author Account `json:"author"`
|
2024-02-02 16:50:23 +00:00
|
|
|
|
2024-07-13 15:16:40 +00:00
|
|
|
Metric PostMetric `json:"metric" gorm:"-"`
|
2024-03-02 17:23:11 +00:00
|
|
|
}
|
2024-07-21 16:49:36 +00:00
|
|
|
|
|
|
|
type PostStoryBody struct {
|
2024-08-18 13:27:55 +00:00
|
|
|
Thumbnail *uint `json:"thumbnail"`
|
|
|
|
Title *string `json:"title"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
Location *string `json:"location"`
|
|
|
|
Attachments []string `json:"attachments"`
|
2024-07-21 16:49:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PostArticleBody struct {
|
2024-08-18 13:27:55 +00:00
|
|
|
Thumbnail *uint `json:"thumbnail"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Description *string `json:"description"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
Attachments []string `json:"attachments"`
|
2024-07-21 16:49:36 +00:00
|
|
|
}
|