types

package
v2.2.0-beta+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2016 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Overview

Package types contains common shared types used throughout the project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board struct {
	Ctr     int64         `json:"ctr"`
	Threads []BoardThread `json:"threads"`
}

Board stores board metadata and the OPs of all threads

func (*Board) MarshalJSON

func (b *Board) MarshalJSON() ([]byte, error)

MarshalJSON ensures b.Threads is marshalled to a JSON array even when nil

type BoardThread

type BoardThread 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"`
	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"`
	LogCtr    int64  `json:"logCtr" gorethink:"logCtr"`
	BumpTime  int64  `json:"bumpTime" gorethink:"bumpTime"`
	ReplyTime int64  `json:"replyTime" gorethink:"replyTime"`
	Board     string `json:"board" gorethink:"board"`
	Subject   string `json:"subject,omitempty" gorethink:"subject"`
}

BoardThread is a stripped down version of Thread for whole-board retrieval queries. Reduces server memory usage and served JSON payload.

type Captcha

type Captcha struct {
	Captcha   string `json:"captcha"`
	CaptchaID string `json:"captchaID"`
}

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

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 coinflip command type
	Flip
	// EightBall is the the #8ball random answer dispenser command type
	EightBall
	// SyncWatch is the syncronised timer command type for syncronising episode
	// time during group anime watching and such
	SyncWatch
	// Pyu - don't ask
	Pyu
)

type DatabasePost

type DatabasePost struct {
	Post
	IP       string `json:"-" gorethink:"ip"`
	Password []byte `json:"-" gorethink:"password"`
}

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   int16                  `gorethink:"postCtr"`
	ImageCtr  int16                  `gorethink:"imageCtr"`
	ID        int64                  `gorethink:"id"`
	BumpTime  int64                  `gorethink:"bumpTime"`
	ReplyTime int64                  `gorethink:"replyTime"`
	Subject   string                 `gorethink:"subject,omitempty"`
	Board     string                 `gorethink:"board"`
	Posts     map[int64]DatabasePost `gorethink:"posts"`
	Log       [][]byte               `gorethink:"log"`
}

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"`
	FileType uint8     `json:"fileType" gorethink:"fileType"`
	Length   int32     `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 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

type LinkMap map[int64]Link

LinkMap contains a map of post numbers, this tread is linking, to corresponding Link structs

type Post

type Post struct {
	Editing   bool      `json:"editing" 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 coppied into the image struct on image allocattion.

type StandalonePost

type StandalonePost struct {
	Post
	OP    int64  `json:"op" gorethink:"op"`
	Board string `json:"board" gorethink:"board"`
}

StandalonePost is an extension of Post for serving through `/json/post/:id`. Regular posts do not contain or need "op" or "board" fields, because they are always retrieved in a known thread context. StandalonePost has these fields to allow serving post parenthood for random posts of 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
	LogCtr    int64          `json:"logCtr" gorethink:"logCtr"`
	BumpTime  int64          `json:"bumpTime" gorethink:"bumpTime"`
	ReplyTime int64          `json:"replyTime" gorethink:"replyTime"`
	Board     string         `json:"board" gorethink:"board"`
	Subject   string         `json:"subject,omitempty" gorethink:"subject"`
	Posts     map[int64]Post `json:"posts,omitempty" gorethink:"posts"`
}

Thread is a transport/export wrapper that stores both the thread metada, its opening post data and its contained posts. The composite type itself is not stored in the database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL