add a couple post endpoints + /timelines/home
This commit is contained in:
parent
dd72a1f4c1
commit
9f052dc9ef
24 changed files with 462 additions and 32 deletions
35
web/api/post.go
Normal file
35
web/api/post.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
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"`
|
||||
|
||||
Blog postPartialBlog `json:"blog"`
|
||||
}
|
||||
|
||||
type postPartialBlog struct {
|
||||
ID ulid.ULID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Domain *string `json:"domain"`
|
||||
}
|
||||
|
||||
func DBPostToPost(p database.Post, b database.Blog) Post {
|
||||
return Post{
|
||||
ID: p.ID,
|
||||
Content: p.Content,
|
||||
Source: p.Source,
|
||||
Visibility: p.Visibility,
|
||||
Blog: postPartialBlog{
|
||||
ID: p.BlogID,
|
||||
Name: b.Name,
|
||||
Domain: b.Domain,
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue