Documentation
¶
Overview ¶
Package types contains common shared types used throughout the project
Index ¶
Constants ¶
const ( JPEG = iota PNG GIF WEBM PDF SVG MP4 MP3 OGG ZIP SevenZip TGZ TXZ )
Supported file formats
Variables ¶
var Extensions = map[uint8]string{ JPEG: "jpg", PNG: "png", GIF: "gif", MP3: "mp3", MP4: "mp4", WEBM: "webm", OGG: "ogg", ZIP: "zip", SevenZip: "7z", TGZ: "tar.gz", TXZ: "tar.xz", }
Extensions maps internal file types to their canonical file extensions
Functions ¶
This section is empty.
Types ¶
type Board ¶
type Board struct {
Ctr int64 `json:"ctr"`
Threads BoardThreads `json:"threads"`
}
Board stores board metadata and the OPs of all threads
func (*Board) MarshalJSON ¶
MarshalJSON ensures b.Threads is marshalled to a JSON array even when nil
type BoardThreads ¶
type BoardThreads []struct {
Locked bool `json:"locked,omitempty" gorethink:"locked"`
Archived bool `json:"archived,omitempty" gorethink:"archived"`
Sticky bool `json:"sticky,omitempty" gorethink:"sticky"`
PostCtr int16 `json:"postCtr" gorethink:"postCtr"`
ImageCtr int16 `json:"imageCtr" gorethink:"imageCtr"`
ID int64 `json:"id" gorethink:"id"`
Time int64 `json:"time" gorethink:"time"`
LastUpdated int64 `json:"lastUpdated" gorethink:"lastUpdated"`
Name string `json:"name,omitempty" gorethink:"name,omitempty"`
Trip string `json:"trip,omitempty" gorethink:"trip,omitempty"`
Auth string `json:"auth,omitempty" gorethink:"auth,omitempty"`
Email string `json:"email,omitempty" gorethink:"email,omitempty"`
Image *Image `json:"image,omitempty" gorethink:"image,omitempty"`
ReplyTime int64 `json:"replyTime" gorethink:"replyTime"`
Board string `json:"board" gorethink:"board"`
Subject string `json:"subject" gorethink:"subject"`
}
BoardThreads is an array stripped down version of Thread for whole-board retrieval queries. Reduces server memory usage and served JSON payload.
func (BoardThreads) Len ¶
func (b BoardThreads) Len() int
func (BoardThreads) Less ¶
func (b BoardThreads) Less(i, j int) bool
func (BoardThreads) Swap ¶
func (b BoardThreads) Swap(i, j int)
type Captcha ¶
type Captcha struct {
Captcha, CaptchaID string
}
Captcha stores captcha data for request messages that require it, if captchas s are enabled
type Command ¶
type Command struct {
Type CommandType `json:"type" gorethink:"type"`
Val interface{} `json:"val" gorethink:"val"`
}
Command contains the type and value array of hash commands, such as dice rolls, #flip, #8ball, etc. The Val field depends on the Type field. Dice: []uint16 Flip: bool EightBall: string SyncWatch: TODO: SyncWatch storage type Pyu: int64 Pcount: int64
type CommandType ¶
type CommandType uint8
CommandType are the various struct types of hash commands and their responses, such as dice rolls, #flip, #8ball, etc.
const ( // Dice is the dice roll command type Dice CommandType = iota // Flip is the coin flip command type Flip // EightBall is the the #8ball random answer dispenser command type EightBall // SyncWatch is the synchronized timer command type for synchronizing // episode time during group anime watching and such SyncWatch // Pyu - don't ask Pyu // Pcount - don't ask Pcount )
type DatabasePost ¶
type DatabasePost struct {
StandalonePost
IP string `gorethink:"ip"`
Password []byte `gorethink:"password"`
Log [][]byte `gorethink:"log"`
LastUpdated int64 `json:"lastUpdated" gorethink:"lastUpdated"`
}
DatabasePost is for writing new posts to a database. It contains the IP and Password fields, which are never exposed publically through Post.
type DatabaseThread ¶
type DatabaseThread struct {
PostCtr int `gorethink:"postCtr"`
ImageCtr int `gorethink:"imageCtr"`
ID int64 `gorethink:"id"`
ReplyTime int64 `gorethink:"replyTime"`
Subject string `gorethink:"subject"`
Board string `gorethink:"board"`
}
DatabaseThread is a template for writing new threads to the database
type Image ¶
type Image struct {
Spoiler bool `json:"spoiler,omitempty" gorethink:"spoiler,omitempty"`
ImageCommon
Name string `json:"name" gorethink:"name"`
}
Image contains a post's image and thumbnail data
type ImageCommon ¶
type ImageCommon struct {
APNG bool `json:"apng,omitempty" gorethink:"apng,omitempty"`
Audio bool `json:"audio,omitempty" gorethink:"audio,omitempty"`
// Only used for file formats like OGG and MP4 that may or may not contain
// video
Video bool `json:"video,omitempty" gorethink:"video,omitempty"`
FileType uint8 `json:"fileType" gorethink:"fileType"`
Length uint32 `json:"length,omitempty" gorethink:"length,omitempty"`
Dims [4]uint16 `json:"dims" gorethink:"dims"`
Size int `json:"size" gorethink:"size"`
MD5 string
SHA1 string
}
ImageCommon contains the common fields of both Image and ProtoImage structs
type Link ¶
type Link struct {
OP int64 `json:"op" gorethink:"op"`
Board string `json:"board" gorethink:"board"`
}
Link stores the target post's parent board and parent thread
type LinkMap ¶
LinkMap contains a map of post numbers, this tread is linking, to corresponding Link structs
type Post ¶
type Post struct {
Editing bool `json:"editing,omitempty" gorethink:"editing"`
ID int64 `json:"id" gorethink:"id"`
Time int64 `json:"time" gorethink:"time"`
Body string `json:"body" gorethink:"body"`
Name string `json:"name,omitempty" gorethink:"name,omitempty"`
Trip string `json:"trip,omitempty" gorethink:"trip,omitempty"`
Auth string `json:"auth,omitempty" gorethink:"auth,omitempty"`
Email string `json:"email,omitempty" gorethink:"email,omitempty"`
Image *Image `json:"image,omitempty" gorethink:"image,omitempty"`
Backlinks LinkMap `json:"backlinks,omitempty" gorethink:"backlinks,omitempty"`
Links LinkMap `json:"links,omitempty" gorethink:"links,omitempty"`
Commands []Command `json:"commands,omitempty" gorethink:"commands,omitempty"`
}
Post is a generic post exposed publically through the JSON API. Either OP or reply.
type ProtoImage ¶
type ProtoImage struct {
ImageCommon
Posts int64 `gorethink:"posts"`
}
ProtoImage stores image data related to the source and thumbnail resources themselves. This struct is partially copied into the image struct on image allocation.
type StandalonePost ¶
type StandalonePost struct {
Post
OP int64 `json:"op" gorethink:"op"`
Board string `json:"board" gorethink:"board"`
}
StandalonePost is a post view that includes the "op" and "board" fields, which are not exposed though Post, but are required for retrieving a post with unknown parenthood.
type Thread ¶
type Thread struct {
Locked bool `json:"locked,omitempty" gorethink:"locked"`
Archived bool `json:"archived,omitempty" gorethink:"archived"`
Sticky bool `json:"sticky,omitempty" gorethink:"sticky"`
PostCtr int16 `json:"postCtr" gorethink:"postCtr"`
ImageCtr int16 `json:"imageCtr" gorethink:"imageCtr"`
Post
ReplyTime int64 `json:"replyTime" gorethink:"replyTime"`
LastUpdated int64 `json:"lastUpdated" gorethink:"lastUpdated"`
Subject string `json:"subject" gorethink:"subject"`
Board string `json:"board" gorethink:"board"`
Posts []Post `json:"posts" gorethink:"posts"`
}
Thread is a transport/export wrapper that stores both the thread metadata, its opening post data and its contained posts. The composite type itself is not stored in the database.