Documentation ¶
Overview ¶
Package common contains common shared types, variables and constants used throughout the project
Index ¶
Constants ¶
const ( JPEG = iota PNG GIF WEBM PDF SVG MP4 MP3 OGG ZIP SevenZip TGZ TXZ )
Supported file formats
const ( MaxLenName = 50 MaxLenAuth = 50 MaxLenPostPassword = 50 MaxLenSubject = 100 MaxLenBody = 2000 MaxLenPassword = 50 MaxLenUserID = 20 MaxLenBoardID = 3 MaxLenBoardTitle = 100 MaxLenNotice = 500 MaxLenRules = 5000 MaxLenEightball = 2000 )
Maximum lengths of various string input fields
const ( // LenSession defines the length of an unpadded base64-encoded account // login session token LenSession = 171 )
Variables ¶
var ( ErrNameTooLong = ErrTooLong("name") ErrSubjectTooLong = ErrTooLong("subject") ErrPostPasswordTooLong = ErrTooLong("post password") ErrBodyTooLong = ErrTooLong("post body") )
Commonly used errors
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 []BoardThread
Board is an array stripped down version of Thread for whole-board retrieval queries. Reduces server memory usage and served JSON payload.
type BoardThread ¶
type BoardThread struct { ThreadCommon ID uint64 `json:"id" gorethink:"id"` Time int64 `json:"time" gorethink:"time"` Name string `json:"name,omitempty" gorethink:"name,omitempty"` Trip string `json:"trip,omitempty" gorethink:"trip,omitempty"` Auth string `json:"auth,omitempty" gorethink:"auth,omitempty"` Image *Image `json:"image,omitempty" gorethink:"image,omitempty"` }
BoardThread is a stripped down version of Thread for board catalog queries
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 LastUpdated int64 `json:"lastUpdated" gorethink:"lastUpdated"` IP string `gorethink:"ip"` Password []byte `gorethink:"password"` Log [][]byte `gorethink:"log"` }
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 uint32 `gorethink:"postCtr"` ImageCtr uint32 `gorethink:"imageCtr"` ID uint64 `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 ErrTooLong ¶
type ErrTooLong string
ErrTooLong is passed, when a field exceeds the maximum string length for that specific field
func (ErrTooLong) Error ¶
func (e ErrTooLong) Error() string
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 uint64 `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 uint64 `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"` 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 uint `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 uint64 `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 { Post ThreadCommon 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.
type ThreadCommon ¶
type ThreadCommon struct { Locked bool `json:"locked,omitempty" gorethink:"locked"` Archived bool `json:"archived,omitempty" gorethink:"archived"` Sticky bool `json:"sticky,omitempty" gorethink:"sticky"` PostCtr uint32 `json:"postCtr" gorethink:"postCtr"` ImageCtr uint32 `json:"imageCtr" gorethink:"imageCtr"` ReplyTime int64 `json:"replyTime" gorethink:"replyTime"` LastUpdated int64 `json:"lastUpdated" gorethink:"lastUpdated"` Subject string `json:"subject" gorethink:"subject"` Board string `json:"board" gorethink:"board"` }
ThreadCommon contains common fields of both BoardThread and Thread