-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathblogpost.go
56 lines (42 loc) · 1.19 KB
/
blogpost.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package kilonova
import (
"log/slog"
"time"
)
// Just a sketch of the concepts behind a blog functionality
type BlogPost struct {
ID int `json:"id"`
CreatedAt time.Time `json:"created_at"`
AuthorID int `json:"author_id"`
Title string `json:"title"`
Slug string `json:"slug"` // unique, used in URL
Visible bool `json:"visible"`
PublishedAt *time.Time `json:"published_at"`
}
func (bp *BlogPost) LogValue() slog.Value {
if bp == nil {
return slog.Value{}
}
return slog.GroupValue(slog.Int("id", bp.ID), slog.String("name", bp.Title))
}
type BlogPostFilter struct {
ID *int `json:"id"`
IDs []int `json:"ids"`
AuthorID *int `json:"author_id"`
Slug *string `json:"slug"`
Limit int `json:"limit"`
Offset int `json:"offset"`
Look bool `json:"-"`
LookingUser *UserBrief `json:"-"`
// Check posts that have attachment with that ID
// Currently used for logging statement changes
AttachmentID *int `json:"-"`
Ordering string `json:"ordering"`
Ascending bool `json:"ascending"`
}
type BlogPostUpdate struct {
Slug *string `json:"slug"`
Visible *bool `json:"visible"`
Title *string `json:"title"`
}
// type UserFollow struct{}