Interactive/pkg/internal/models/posts.go

53 lines
1.5 KiB
Go
Raw Normal View History

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
"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-05-15 11:45:49 +00:00
type Post struct {
2024-02-02 15:42:42 +00:00
BaseModel
2024-07-21 17:19:23 +00:00
Type string `json:"type"`
Body datatypes.JSONMap `json:"body"`
Language string `json:"language"`
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
IsDraft bool `json:"is_draft"`
2024-03-10 10:38:42 +00:00
PublishedAt *time.Time `json:"published_at"`
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
}
type PostStoryBody struct {
Title *string `json:"title"`
Content string `json:"content"`
Location *string `json:"location"`
Attachments []uint `json:"attachments"`
}
type PostArticleBody struct {
Title string `json:"title"`
Description *string `json:"description"`
Content string `json:"content"`
Attachments []uint `json:"attachments"`
}