2023-09-06 16:32:33 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.sleepycat.moe/sam/mercury/internal/database"
|
|
|
|
"github.com/oklog/ulid/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Post struct {
|
|
|
|
ID ulid.ULID `json:"id"`
|
|
|
|
Content *string `json:"content"`
|
|
|
|
Source *string `json:"source"`
|
|
|
|
Visibility database.PostVisibility `json:"visibility"`
|
|
|
|
|
2023-09-15 16:33:08 +02:00
|
|
|
Blog Blog `json:"blog"`
|
2023-09-06 16:32:33 +02:00
|
|
|
}
|
|
|
|
|
2023-09-15 16:33:08 +02:00
|
|
|
func DBPostToPost(p database.Post, b database.Blog, a database.Account) Post {
|
2023-09-06 16:32:33 +02:00
|
|
|
return Post{
|
|
|
|
ID: p.ID,
|
|
|
|
Content: p.Content,
|
|
|
|
Source: p.Source,
|
|
|
|
Visibility: p.Visibility,
|
2023-09-15 16:33:08 +02:00
|
|
|
Blog: DBBlogToBlog(b, a),
|
2023-09-06 16:32:33 +02:00
|
|
|
}
|
|
|
|
}
|