37 lines
745 B
Go
37 lines
745 B
Go
|
package api
|
||
|
|
||
|
import (
|
||
|
"git.sleepycat.moe/sam/mercury/internal/database"
|
||
|
"github.com/oklog/ulid/v2"
|
||
|
)
|
||
|
|
||
|
// Blog is the basic blog returned by endpoints.
|
||
|
type Blog struct {
|
||
|
ID ulid.ULID `json:"id"`
|
||
|
Name string `json:"name"`
|
||
|
Domain *string `json:"domain"`
|
||
|
Bio string `json:"bio"`
|
||
|
|
||
|
Account blogPartialAccount `json:"account"`
|
||
|
}
|
||
|
|
||
|
type blogPartialAccount struct {
|
||
|
ID ulid.ULID `json:"id"`
|
||
|
Username string `json:"username"`
|
||
|
Domain *string `json:"domain"`
|
||
|
}
|
||
|
|
||
|
func DBBlogToBlog(b database.Blog, a database.Account) Blog {
|
||
|
return Blog{
|
||
|
ID: b.ID,
|
||
|
Name: b.Name,
|
||
|
Domain: b.Domain,
|
||
|
Bio: b.Bio,
|
||
|
Account: blogPartialAccount{
|
||
|
ID: a.ID,
|
||
|
Username: a.Username,
|
||
|
Domain: a.Domain,
|
||
|
},
|
||
|
}
|
||
|
}
|