apitypes

package
v0.36.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIdx            = errors.New("invalid idx")
	ErrInvalidBoardArticleID = errors.New("invalid board-article-id")
)
View Source
var BOARD_DETAIL_FIELD_MAP = map[string]string{
	"type":                 schema.BOARD_BOARD_TYPE_b,
	"moderators":           schema.BOARD_BMS_b,
	"last_post_time":       schema.BOARD_LAST_POST_TIME_b,
	"update_time":          schema.BOARD_UPDATE_NANO_TS_b,
	"vtime":                schema.BOARD_VOTE_CLOSING_TIME_b,
	"last_set_time":        schema.BOARD_LAST_SET_TIME_b,
	"link_pttbid":          schema.BOARD_POST_EXPIRE_b,
	"end_gamble":           schema.BOARD_END_GAMBLE_NANO_TS_b,
	"fast_recommend_pause": schema.BOARD_FAST_RECOMMEND_PAUSE_b,
	"gid":                  schema.BOARD_GID_b,
}

Functions

func DeserializeCommentIdx

func DeserializeCommentIdx(theIdx string) (sortNanoTS types.NanoTS, commentID types.CommentID)

func DeserializeContentIdx

func DeserializeContentIdx(theIdx string) (contentID types.ContentID, contentIdx int, err error)

func SerializeArticleCommentIdx

func SerializeArticleCommentIdx(theType ArticleCommentType, idx string) string

func SerializeCommentIdx

func SerializeCommentIdx(sortNanoTS types.NanoTS, commentID types.CommentID) string

func SerializeContentIdx

func SerializeContentIdx(contentID types.ContentID, contentIdx int) (theIdx string)

func ToFTitle

func ToFTitle(title string) string

func ToURL

func ToURL(fbboardID FBoardID, farticleID FArticleID) string

Types

type ArticleComment

type ArticleComment struct {
	FBoardID   FBoardID    `json:"bid"`         //
	FArticleID FArticleID  `json:"aid"`         //
	IsDeleted  bool        `json:"deleted"`     //
	CreateTime types.Time8 `json:"create_time"` //
	MTime      types.Time8 `json:"modified"`    //
	Recommend  int         `json:"recommend"`   //
	NComments  int         `json:"n_comments"`  //
	Owner      bbs.UUserID `json:"owner"`       //
	Title      string      `json:"title"`       //
	Money      int         `json:"money"`       //
	Class      string      `json:"class"`       // can be: R: 轉, [class]

	URL  string           `json:"url"`  //
	Read types.ReadStatus `json:"read"` //

	Idx string `json:"idx"`

	Rank int `json:"rank"`

	TheType ArticleCommentType `json:"type"`

	CommentID         types.CommentID     `json:"cid,omitempty"`
	CommentType       ptttype.CommentType `json:"ctype,omitempty"`
	CommentCreateTime types.Time8         `json:"ctime,omitempty"`
	Comment           [][]*types.Rune     `json:"comment,omitempty"`

	TokenUser bbs.UUserID `json:"tokenuser"`
}

func NewArticleCommentFromArticle

func NewArticleCommentFromArticle(a_db *schema.ArticleSummary) *ArticleComment

func NewArticleCommentFromComment

func NewArticleCommentFromComment(a_db *schema.ArticleSummary, c_db *schema.CommentSummary) *ArticleComment

type ArticleCommentIdx

type ArticleCommentIdx string

type ArticleCommentType

type ArticleCommentType string
const (
	ARTICLE_COMMENT_TYPE_ARTICLE ArticleCommentType = "a"
	ARTICLE_COMMENT_TYPE_COMMENT ArticleCommentType = "c"
)

func DeserializeArticleCommentIdx

func DeserializeArticleCommentIdx(theIdx string) (theType ArticleCommentType, subIdx string, err error)

type ArticleSummary

type ArticleSummary struct {
	FBoardID   FBoardID         `json:"bid"`         //
	ArticleID  FArticleID       `json:"aid"`         //
	IsDeleted  bool             `json:"deleted"`     //
	CreateTime types.Time8      `json:"create_time"` //
	MTime      types.Time8      `json:"modified"`    //
	Recommend  int              `json:"recommend"`   //
	NComments  int              `json:"n_comments"`  //
	Owner      bbs.UUserID      `json:"owner"`       //
	Title      string           `json:"title"`       //
	Money      int              `json:"money"`       //
	Class      string           `json:"class"`       // can be: R: 轉, [class]
	Filemode   ptttype.FileMode `json:"mode"`        //

	URL  string `json:"url"`  //
	Read bool   `json:"read"` //

	Idx string `json:"idx"`

	Rank int `json:"rank"`

	SubjectType ptttype.SubjectType `json:"subject_type"`

	TokenUser bbs.UUserID `json:"tokenuser"`

	Editable  bool `json:"editable"`
	Deletable bool `json:"deletable"`
}

func NewArticleSummary

func NewArticleSummary(a_db *schema.ArticleSummary, userID bbs.UUserID) *ArticleSummary

func NewArticleSummaryFromWithRegex

func NewArticleSummaryFromWithRegex(a_db *schema.ArticleSummaryWithRegex, userID bbs.UUserID) *ArticleSummary

type BoardDetail

type BoardDetail struct {
	FBoardID     FBoardID        `json:"bid"`
	Brdname      string          `json:"brdname"`
	Title        string          `json:"title"`
	BrdAttr      ptttype.BrdAttr `json:"flag"`
	BoardType    string          `json:"type"`
	Category     string          `json:"class"`
	NUser        int             `json:"nuser"`
	BMs          []bbs.UUserID   `json:"moderators"`
	Reason       string          `json:"reason"`
	Read         bool            `json:"read"`
	Total        int             `json:"total"`
	LastPostTime types.Time8     `json:"last_post_time"`

	UpdateTime types.Time8 `json:"update_time"`

	VoteLimitLogins  int `json:"vote_limit_logins"`
	PostLimitLogins  int `json:"post_limit_logins"`
	VoteLimitBadpost int `json:"vote_limit_bad_post"`
	PostLimitBadpost int `json:"post_limit_bad_post"`

	NVote           int         `json:"vote"`
	VoteClosingTime types.Time8 `json:"vtime"`

	Level              ptttype.PERM `json:"level"`
	LastSetTime        types.Time8  `json:"last_set_time"` /* perm-reload */
	PostExpire         ptttype.Bid  `json:"link_pttbid"`   /* 看板連結的 bid */
	PostType           []string     `json:"post_type"`
	PostTemplate       []bool       `json:"post_tmpl"`
	EndGambleNanoTS    types.Time8  `json:"end_gamble"`
	FastRecommendPause types.Time8  `json:"fast_recommend_pause"`

	ChessCountry ptttype.ChessCode `json:"chesscountry"`

	LevelIdx schema.LevelIdx `json:"level_idx,omitempty"`

	Gid ptttype.Bid `json:"gid"`
	Bid ptttype.Bid `json:"pttbid"`

	Idx string `json:"idx"`

	TokenUser bbs.UUserID `json:"tokenuser"`
}

func NewBoardDetail

func NewBoardDetail(b_db *schema.BoardDetail, idx string, userID bbs.UUserID) *BoardDetail

type BoardSummary

type BoardSummary struct {
	FBoardID     FBoardID        `json:"bid"`
	Brdname      string          `json:"brdname"`
	Title        string          `json:"title"`
	BrdAttr      ptttype.BrdAttr `json:"flag"`
	BoardType    string          `json:"type"`
	Category     string          `json:"class"`
	NUser        int             `json:"nuser"`
	BMs          []bbs.UUserID   `json:"moderators"`
	Reason       string          `json:"reason"`
	Read         bool            `json:"read"`
	Fav          bool            `json:"fav"`
	Total        int             `json:"total"`
	LastPostTime types.Time8     `json:"last_post_time"`

	StatAttr ptttype.BoardStatAttr `json:"stat_attr,omitempty"`
	LevelIdx schema.LevelIdx       `json:"level_idx,omitempty"` // sub-level-idx for folder, "" if type is line or board.

	URL string `json:"url,omitempty"`

	Gid ptttype.Bid `json:"gid"`
	Bid ptttype.Bid `json:"pttbid"`

	Idx string `json:"idx"`

	TokenUser bbs.UUserID `json:"tokenuser,omitempty"`
}

func NewBoardSummary

func NewBoardSummary(b_db *schema.BoardSummary, idx string, userBoardInfo *UserBoardInfo, userID bbs.UUserID) *BoardSummary

func NewBoardSummaryFromUserFavorites

func NewBoardSummaryFromUserFavorites(userID bbs.UUserID, uf_db *schema.UserFavorites, b_db *schema.BoardSummary, userBoardInfo *UserBoardInfo) *BoardSummary

type Comment

type Comment struct {
	FBoardID   FBoardID            `json:"bid"`
	FArticleID FArticleID          `json:"aid"`
	CommentID  types.CommentID     `json:"cid"`
	TheType    ptttype.CommentType `json:"type"`
	RefID      types.CommentID     `json:"refid"`
	IsDeleted  bool                `json:"deleted"`
	CreateTime types.Time8         `json:"create_time"`
	SortTime   types.Time8         `json:"sort_time"`
	Owner      bbs.UUserID         `json:"owner"`
	Content    [][]*types.Rune     `json:"content"`
	IP         string              `json:"ip"`
	Host       string              `json:"host"` // ip 的中文呈現, 外國則為國家.
	Idx        string              `json:"idx"`

	TokenUser bbs.UUserID `json:"tokenuser"`
}

func NewComment

func NewComment(comment_db *schema.Comment, userID bbs.UUserID) (comment *Comment)

type DeleteCommentParams

type DeleteCommentParams struct {
	CommentID types.CommentID `json:"cid" form:"cid" url:"cid"`
	Reason    string          `json:"reason" form:"reason" url:"reason"`
}

func (*DeleteCommentParams) ToComment

func (d *DeleteCommentParams) ToComment(comment *schema.Comment, userID bbs.UUserID, remoteAddr string, updateNanoTS types.NanoTS) (newComment *schema.Comment)

type FArticleID

type FArticleID string

FArticleID as article-id for frontend.

func ToFArticleID

func ToFArticleID(articleID bbs.ArticleID) FArticleID

func ToFArticleIDFromManArticleID

func ToFArticleIDFromManArticleID(articleID types.ManArticleID) FArticleID

func (FArticleID) ToArticleID

func (f FArticleID) ToArticleID() bbs.ArticleID

func (FArticleID) ToManArticleID

func (f FArticleID) ToManArticleID() types.ManArticleID

type FBoardID

type FBoardID string

FBoardID as board-id for frontend.

func ToFBoardID

func ToFBoardID(boardID bbs.BBoardID) FBoardID

func (FBoardID) ToBBoardID

func (f FBoardID) ToBBoardID() (boardID bbs.BBoardID, err error)

type ManArticleSummary

type ManArticleSummary struct {
	FBoardID   FBoardID    `json:"bid"`         //
	ArticleID  FArticleID  `json:"aid"`         //
	LevelIdx   FArticleID  `json:"level_idx"`   //
	CreateTime types.Time8 `json:"create_time"` //
	MTime      types.Time8 `json:"modified"`    //

	Title string `json:"title"` //

	IsDir bool `json:"is_dir"`

	TokenUser bbs.UUserID `json:"tokenuser"`
}

func NewManArticleSummary

func NewManArticleSummary(articleSummary_db *schema.ManArticleSummary, userID bbs.UUserID) (articleSummary *ManArticleSummary)

type ReplyCommentParams

type ReplyCommentParams struct {
	CommentID types.CommentID `json:"cid" form:"cid" url:"cid"`
	Content   [][]*types.Rune `json:"content" form:"content" url:"content"`
}

func (*ReplyCommentParams) ToComment

func (r *ReplyCommentParams) ToComment(userID bbs.UUserID, remoteAddr string, boardID bbs.BBoardID, articleID bbs.ArticleID, commentSortTime types.NanoTS, updateNanoTS types.NanoTS) (replyComment *schema.Comment)

ToComment

referring to:

dbcs.parseReply
dbcs.EDBlock.ForwardInferTS

type UserBoardInfo

type UserBoardInfo struct {
	Read bool
	Fav  bool
	Stat ptttype.BoardStatAttr
}

Jump to

Keyboard shortcuts

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