-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
86 lines (75 loc) · 2.51 KB
/
structs.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//go:generate easyjson --all --no_std_marshalers $GOFILE
package config
// Configs stores the global server configuration
type Configs struct {
Public
PruneBoards bool `json:"pruneBoards"`
Pyu bool `json:"pyu"`
HideNSFW bool `json:"hideNSFW"`
JPEGQuality uint8
MaxWidth uint16 `json:"maxWidth"`
MaxHeight uint16 `json:"maxHeight"`
BoardExpiry uint `json:"boardExpiry"`
MaxSize uint `json:"maxSize"`
SessionExpiry uint `json:"sessionExpiry"`
RootURL string `json:"rootURL"`
Salt string `json:"salt"`
FeedbackEmail string `json:"feedbackEmail"`
FAQ string
}
// Public contains configurations exposeable through public availability APIs
type Public struct {
Captcha bool `json:"captcha"`
Mature bool `json:"mature"`
DisableUserBoards bool `json:"disableUserBoards"`
PruneThreads bool `json:"pruneThreads"`
ThreadExpiryMin uint `json:"threadExpiryMin"`
ThreadExpiryMax uint `json:"threadExpiryMax"`
DefaultLang string `json:"defaultLang"`
DefaultCSS string `json:"defaultCSS"`
ImageRootOverride string `json:"imageRootOverride"`
Links map[string]string `json:"links"`
}
// BoardConfigs stores board-specific configuration
type BoardConfigs struct {
BoardPublic
DisableRobots bool `json:"disableRobots"`
ID string `json:"id"`
Eightball []string `json:"eightball"`
}
// BoardPublic contains publically accessible board-specific configurations
type BoardPublic struct {
ReadOnly bool `json:"readOnly"`
TextOnly bool `json:"textOnly"`
ForcedAnon bool `json:"forcedAnon"`
Flags bool `json:"flags"`
NonLive bool `json:"nonLive"`
NSFW bool
DefaultCSS string `json:"defaultCSS"`
Title string `json:"title"`
Notice string `json:"notice"`
Rules string `json:"rules"`
}
// BoardConfContainer contains configurations for an individual board as well
// as pregenerated public JSON and it's hash
type BoardConfContainer struct {
BoardConfigs
JSON []byte
Hash string
}
// BoardTitle contains a board's ID and title
type BoardTitle struct {
ID string `json:"id"`
Title string `json:"title"`
}
// BoardTitles implements sort.Interface
type BoardTitles []BoardTitle
func (b BoardTitles) Len() int {
return len(b)
}
func (b BoardTitles) Less(i, j int) bool {
return b[i].ID < b[j].ID
}
func (b BoardTitles) Swap(i, j int) {
b[i], b[j] = b[j], b[i]
}