api

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: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_MAX_ARTICLE_BLOCK_LIST = 1
	DEFAULT_MAX_LIST               = 200
	DEFAULT_DESCENDING             = true
	DEFAULT_ASCENDING              = true

	ARTICLE_LOCK_TS          = 10
	ARTICLE_LOCK_TS_DURATION = time.Duration(ARTICLE_LOCK_TS) * time.Second
	ARTICLE_LOCK_NANO_TS     = types.NanoTS(ARTICLE_LOCK_TS) * types.TS_TO_NANO_TS

	HTML_CACHE_CONTROL_TS = 3600
	JS_CACHE_CONTROL_TS   = 86400 * 365

	OFFSET_MTIME_NANO_TS = 1000000000 // 1 second
)
View Source
const (
	ROOT_HTML_R  = "/"
	INDEX_HTML_R = "/index.html"
)
View Source
const ADD_FAVORITE_BOARD_R = "/user/:user_id/favorites/addboard"
View Source
const ADD_FAVORITE_FOLDER_R = "/user/:user_id/favorites/addfolder"
View Source
const ADD_FAVORITE_LINE_R = "/user/:user_id/favorites/addline"
View Source
const ARTICLES_HTML_R = "/board/:bid/articles"
View Source
const ARTICLE_HTML_R = "/board/:bid/article/:aid"
View Source
const ATTEMPT_CHANGE_EMAIL_R = "/user/:user_id/attemptchangeemail"
View Source
const ATTEMPT_REGISTER_USER_R = "/account/attemptregister"
View Source
const ATTEMPT_SET_ID_EMAIL_R = "/user/:user_id/attemptsetidemail"
View Source
const BOARDS_FAVORITES_HTML_R = "/user/:user_id/favorites"
View Source
const BOARDS_HTML_R = "/boards"
View Source
const BOARDS_POPULAR_HTML_R = "/boards/popular"
View Source
const CHANGE_EMAIL_R = "/user/:user_id/changeemail"
View Source
const CHANGE_PASSWD_R = "/user/:user_id/updatepasswd" //nolint // passwd as route
View Source
const CHECK_EXISTS_USER_R = "/account/existsuser"
View Source
const CLS_BOARDS_HTML_R = "/cls/:cls_id"
View Source
const CREATE_ARTICLE_HTML_R = "/board/:bid/post"
View Source
const CREATE_ARTICLE_R = "/board/:bid/article"
View Source
const CREATE_BOARD_R = "/class/:cls/board"
View Source
const CREATE_COMMENT_R = "/board/:bid/article/:aid/comment"
View Source
const CREATE_RANK_R = "/board/:bid/article/:aid/rank"
View Source
const CROSS_POST_R = "/board/:bid/article/:aid/crosspost"
View Source
const (
	DEFAULT_FAV_TITLE = "新的目錄"
)
View Source
const DELETE_ARTICLES_R = "/board/:bid/deletearticles"
View Source
const DELETE_COMMENTS_R = "/board/:bid/article/:aid/deletecomments"
View Source
const DELETE_FAVORITE_R = "/user/:user_id/favorites/delete"
View Source
const EDIT_ARTICLE_R = "/board/:bid/article/:aid/edit"
View Source
const GET_ARTICLE_BLOCKS_R = "/board/:bid/articleblocks/:aid"
View Source
const GET_ARTICLE_R = "/board/:bid/article/:aid"
View Source
const GET_BOARD_DETAIL_R = "/board/:bid"
View Source
const GET_BOARD_SUMMARY_R = "/board/:bid/summary"
View Source
const GET_MAN_ARTICLE_BLOCKS_R = "/board/:bid/manualblocks/*aid"
View Source
const GET_MAN_ARTICLE_R = "/board/:bid/manual/*aid"
View Source
const GET_USER_ID_R = "/userid"
View Source
const GET_USER_INFO_R = "/user/:user_id"
View Source
const GET_USER_VISIT_COUNT_R = "/uservisitcount"
View Source
const GET_VERSION_R = "/version"
View Source
const INDEX_R = "/"
View Source
const LOAD_ARTICLE_COMMENTS_R = "/board/:bid/article/:aid/comments"
View Source
const LOAD_AUTO_COMPLETE_BOARDS_R = "/boards/autocomplete"
View Source
const LOAD_BOTTOM_ARTICLES_R = "/board/:bid/articles/bottom"
View Source
const LOAD_CLASS_BOARDS_R = "/cls/:clsid"
View Source
const LOAD_FAVORITE_BOARDS_R = "/user/:user_id/favorites"
View Source
const LOAD_GENERAL_ARTICLES_R = "/board/:bid/articles"
View Source
const LOAD_GENERAL_BOARDS_BY_CLASS_R = "/boards/byclass"
View Source
const LOAD_GENERAL_BOARDS_R = "/boards"
View Source
const LOAD_MAN_ARTICLES_R = "/board/:bid/manuals"
View Source
const LOAD_POPULAR_ARTICLES_R = "/articles/popular"
View Source
const LOAD_POPULAR_BOARDS_R = "/boards/popular"
View Source
const LOAD_USER_ARTICLES_R = "/user/:user_id/articles"
View Source
const LOAD_USER_COMMENTS_R = "/user/:user_id/comments"
View Source
const LOGIN_HTML_R = "/login"
View Source
const LOGIN_R = "/account/login"
View Source
const LOGOUT_R = "/account/logout"
View Source
const (
	MAX_USER_FAVORITES_BUF_SIZE = 65535
)
View Source
const REFRESH_R = "/account/refresh"
View Source
const REGISTER_CLIENT_R = "/client/register"
View Source
const REGISTER_HTML_R = "/register"
View Source
const REGISTER_USER_R = "/account/register"
View Source
const REPLY_COMMENTS_R = "/board/:bid/article/:aid/replycomments"
View Source
const SET_ID_EMAIL_R = "/user/:user_id/setidemail"
View Source
const USER_ATTEMPT_CHANGE_EMAIL_HTML_R = "/user/:user_id/attemptchangeemail"
View Source
const USER_ATTEMPT_SET_ID_EMAIL_HTML_R = "/user/:user_id/attemptsetidemail"
View Source
const USER_CHANGE_EMAIL_HTML_R = "/user/:user_id/changeemail"
View Source
const USER_CHANGE_PASSWD_HTML_R = "/user/:user_id/resetpassword" //nolint // passwd as route
View Source
const USER_HTML_R = "/user/:user_id"
View Source
const USER_SET_ID_EMAIL_HTML_R = "/user/:user_id/setidemail"

Variables

View Source
var (
	GET_ARTICLE_CONTENT_INFO_TOO_SOON_NANO_TS = ARTICLE_LOCK_NANO_TS + types.NanoTS(1)*types.TS_TO_NANO_TS // 10 + 1 seconds.

	MIME_TYPE_MAP = map[string]string{
		".js":   "text/javascript",
		".html": "text/html",
		".map":  "application/json",
	}
)
View Source
var (
	ErrInvalidRemoteAddr = errors.New("invalid remote addr")

	ErrInvalidParams            = errors.New("invalid params")
	ErrLoginFailed              = errors.New("login failed")
	ErrNotImplemented           = errors.New("not implemented")
	ErrInvalidPath              = errors.New("invalid path")
	ErrInvalidToken             = errors.New("invalid token")
	ErrInvalidOrigin            = errors.New("invalid origin")
	ErrInvalidBackendStatusCode = errors.New("invalid backend status code")
	ErrNoUser                   = errors.New("no user")
	ErrNoBoard                  = errors.New("no board")
	ErrNoArticle                = errors.New("no article")
	ErrNoUserBoard              = errors.New("no user board")

	ErrAlreadyDeleted = errors.New("already deleted")
	ErrFileNotFound   = errors.New("file not found")

	ErrInvalidUser   = errors.New("invalid user")
	ErrInvalidClient = errors.New("invalid client")

	ErrAlreadyExists = errors.New("already exists")

	ErrInvalidFav = errors.New("invalid fav")

	ErrNotFriend     = errors.New("not friend")
	ErrBoardBlocked  = errors.New("board blocked")
	ErrBoardReported = errors.New("board reported")
	ErrBoardBucket   = errors.New("board bucket")

	ErrPermBoardCreatePermission = errors.New("no board create permission")

	ErrPermBoardReadHidden   = errors.New("hidden board")
	ErrPermBoardReadBlocked  = errors.New("blocked board")
	ErrPermBoardReadReported = errors.New("reported board")

	ErrPermBoardReadNotOver18  = errors.New("not over18")
	ErrPermBoardReadPermission = errors.New("no board read permission")

	ErrPermPostReadOnly        = errors.New("read only")
	ErrPermPostBannedByBoard   = errors.New("banned by board")
	ErrPermBoardPostPost       = errors.New("no user post permission")
	ErrPermBoardPostRestricted = errors.New("only board friends")
	ErrPermBoardPostViolateLaw = errors.New("violate law")
	ErrPermBoardPostPermission = errors.New("no board post permission")

	ErrPermBoardPostLoginDays = errors.New("invalid login days")
	ErrPermBoardPostPostLimit = errors.New("reached post limit")

	ErrPermBoardEditPermission = errors.New("no board edit permission")
)
View Source
var COOLDOWN_LIMIT = []*CooldownLimit{
	{NUser: 4000, Posttime: 1},
	{NUser: 2000, Posttime: 2},
	{NUser: 1000, Posttime: 3},
	{NUser: 0, Posttime: 10},
}
View Source
var (
	IsTest = false
)

Functions

func AddFavoriteBoard

func AddFavoriteBoard(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func AddFavoriteBoardWrapper

func AddFavoriteBoardWrapper(c *gin.Context)

func AddFavoriteFolder

func AddFavoriteFolder(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func AddFavoriteFolderWrapper

func AddFavoriteFolderWrapper(c *gin.Context)

func AddFavoriteLine

func AddFavoriteLine(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func AddFavoriteLineWrapper

func AddFavoriteLineWrapper(c *gin.Context)

func AllHTMLWrapper

func AllHTMLWrapper(c *gin.Context)

func ArticleLockKey

func ArticleLockKey(boardID bbs.BBoardID, articleID bbs.ArticleID) (key string)

func AttemptChangeEmail

func AttemptChangeEmail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func AttemptChangeEmailWrapper

func AttemptChangeEmailWrapper(c *gin.Context)

func AttemptRegisterUser

func AttemptRegisterUser(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func AttemptRegisterUserWrapper

func AttemptRegisterUserWrapper(c *gin.Context)

func AttemptSetIDEmail

func AttemptSetIDEmail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func AttemptSetIDEmailWrapper

func AttemptSetIDEmailWrapper(c *gin.Context)

func ChangeEmail

func ChangeEmail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func ChangeEmailWrapper

func ChangeEmailWrapper(c *gin.Context)

func ChangePasswd

func ChangePasswd(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func ChangePasswdWrapper

func ChangePasswdWrapper(c *gin.Context)

func CheckExistsUser

func CheckExistsUser(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func CheckExistsUserWrapper

func CheckExistsUserWrapper(c *gin.Context)

func CheckUserArticlePermDeletable added in v0.36.0

func CheckUserArticlePermDeletable(userID bbs.UUserID, boardID bbs.BBoardID, articleID bbs.ArticleID, c *gin.Context) (err error)

CheckUserArticlePermDeletable

Deletable

func CheckUserArticlePermEditable added in v0.36.0

func CheckUserArticlePermEditable(userID bbs.UUserID, boardID bbs.BBoardID, articleID bbs.ArticleID, isCheckBoard bool, c *gin.Context) (err error)

CheckUserArticlePermEditable

Editable

func CheckUserArticlePermReadable added in v0.36.0

func CheckUserArticlePermReadable(userID bbs.UUserID, boardID bbs.BBoardID, articleID bbs.ArticleID, isCheckBoard bool, c *gin.Context) (err error)

CheckUserArticlePermReadable

Readable

func CheckUserArticlesPermDeletable added in v0.36.0

func CheckUserArticlesPermDeletable(userID bbs.UUserID, boardID bbs.BBoardID, articleIDs []bbs.ArticleID, userBoardPermReadable *UserBoardPermReadable, c *gin.Context) (articlePermMap map[bbs.ArticleID]error, err error)

CheckUserArticlePermDeletable

Deletable

func CheckUserArticlesPermEditable added in v0.36.0

func CheckUserArticlesPermEditable(userID bbs.UUserID, boardID bbs.BBoardID, articleIDs []bbs.ArticleID, userBoardPerm *UserBoardPermReadable, c *gin.Context) (articlePermMap map[bbs.ArticleID]error, err error)
CheckUserArticlesPermEditable

articles Editable

func CheckUserArticlesPermEditableDeletable added in v0.36.0

func CheckUserArticlesPermEditableDeletable(userID bbs.UUserID, boardID bbs.BBoardID, articleIDs []bbs.ArticleID, userBoardPerm *UserBoardPermReadable, c *gin.Context) (articlePermEditableMap map[bbs.ArticleID]error, articlePermDeletableMap map[bbs.ArticleID]error, err error)
CheckUserArticlesPermEditable

articles Editable

func CheckUserBoardPermCreatable added in v0.36.0

func CheckUserBoardPermCreatable(userID bbs.UUserID, c *gin.Context) (err error)

CheckUserBoardPermCreatable

func CheckUserBoardPermEditable added in v0.36.0

func CheckUserBoardPermEditable(userID bbs.UUserID, boardID bbs.BBoardID, c *gin.Context) (err error)

CheckUserBoardPermEditable

func CheckUserBoardPermPostable added in v0.36.0

func CheckUserBoardPermPostable(userID bbs.UUserID, boardID bbs.BBoardID, c *gin.Context) (err error)

CheckUserBoardPermPostable

https://github.com/ptt/pttbbs/blob/master/mbbsd/cache.c#L209

func CreateArticle

func CreateArticle(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func CreateArticleWrapper

func CreateArticleWrapper(c *gin.Context)

func CreateBoard

func CreateBoard(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func CreateBoardWrapper

func CreateBoardWrapper(c *gin.Context)

func CreateComment

func CreateComment(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func CreateCommentWrapper

func CreateCommentWrapper(c *gin.Context)

func CreateRank

func CreateRank(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func CreateRankWrapper

func CreateRankWrapper(c *gin.Context)

func CrossPost

func CrossPost(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func CrossPostWrapper

func CrossPostWrapper(c *gin.Context)

func DeleteArticles

func DeleteArticles(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

DeleteArticles provides function from api /board/:bid/deletearticles it will call backend api (go-pttbbs) and deleting all components like: comments, ranks, user_read_records about this articles

func DeleteArticlesWrapper

func DeleteArticlesWrapper(c *gin.Context)

func DeleteComments

func DeleteComments(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func DeleteCommentsWrapper

func DeleteCommentsWrapper(c *gin.Context)

func DeleteFavorite

func DeleteFavorite(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func DeleteFavoriteWrapper

func DeleteFavoriteWrapper(c *gin.Context)

func DeserializeArticlesAndUpdateDB

func DeserializeArticlesAndUpdateDB(articleSummaries_b []*bbs.ArticleSummary, updateNanoTS types.NanoTS) (articleSummaries []*schema.ArticleSummaryWithRegex, err error)

func DeserializeBoardDetailsAndUpdateDB

func DeserializeBoardDetailsAndUpdateDB(boardDetails_b []*bbs.BoardDetail, updateNanoTS types.NanoTS) (boardDetails []*schema.BoardDetail, err error)

DeserializeBoards

each_b.Reason happens only with invalid permission.

func DeserializeBoardsAndUpdateDB

func DeserializeBoardsAndUpdateDB(boardSummaries_b []*bbs.BoardSummary, updateNanoTS types.NanoTS) (boardSummaries []*schema.BoardSummary, err error)

DeserializeBoards

each_b.Reason happens only with invalid permission.

func DeserializePBArticlesAndUpdateDB

func DeserializePBArticlesAndUpdateDB(boardID bbs.BBoardID, articleSummaries_b []*boardd.Post, updateNanoTS types.NanoTS, isBottom bool) (articleSummaries []*schema.ArticleSummaryWithRegex, err error)

func DeserializePBBoardsAndUpdateDB

func DeserializePBBoardsAndUpdateDB(boardSummaries_b []*boardd.Board, updateNanoTS types.NanoTS) (boardSummaries []*schema.BoardSummary, err error)

DeserializePBBoardsAndUpdateDB

func DeserializePBManArticlesAndUpdateDB

func DeserializePBManArticlesAndUpdateDB(boardID bbs.BBoardID, levelIdx types.ManArticleID, entries []*mand.Entry, updateNanoTS types.NanoTS) (articleSummaries []*schema.ManArticleSummary, err error)

func EditArticleDetail

func EditArticleDetail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func EditArticleDetailWrapper

func EditArticleDetailWrapper(c *gin.Context)

func ErrBoardCooldown added in v0.36.0

func ErrBoardCooldown(diffNanoTS types.NanoTS) error

func ErrBoardPosttime added in v0.36.0

func ErrBoardPosttime(diffNanoTS types.NanoTS) error

func ErrFloodReject added in v0.36.0

func ErrFloodReject(diffNanoTS types.NanoTS) error

func Form

func Form(theFunc APIFunc, params interface{}, c *gin.Context)

func FormJSON

func FormJSON(theFunc APIFunc, params interface{}, c *gin.Context)

func FormLogout

func FormLogout(theFunc APIFunc, params interface{}, c *gin.Context)

func GetArticleBlocks

func GetArticleBlocks(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetArticleBlocksWrapper

func GetArticleBlocksWrapper(c *gin.Context)

func GetArticleDetail

func GetArticleDetail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetArticleDetailWrapper

func GetArticleDetailWrapper(c *gin.Context)

func GetBoardDetail

func GetBoardDetail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetBoardDetailWrapper

func GetBoardDetailWrapper(c *gin.Context)

func GetBoardSummary

func GetBoardSummary(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetBoardSummaryWrapper

func GetBoardSummaryWrapper(c *gin.Context)

func GetManArticleBlocks

func GetManArticleBlocks(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetManArticleBlocksWrapper

func GetManArticleBlocksWrapper(c *gin.Context)

func GetManArticleDetail

func GetManArticleDetail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetManArticleDetailWrapper

func GetManArticleDetailWrapper(c *gin.Context)

func GetUserID

func GetUserID(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetUserIDWrapper

func GetUserIDWrapper(c *gin.Context)

func GetUserInfo

func GetUserInfo(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetUserInfoWrapper

func GetUserInfoWrapper(c *gin.Context)

func GetUserVisitCount

func GetUserVisitCount(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetUserVisitCountWrapper

func GetUserVisitCountWrapper(c *gin.Context)

func GetVersion

func GetVersion(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func GetVersionWrapper

func GetVersionWrapper(c *gin.Context)

func Index

func Index(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func IndexHTMLWrapper

func IndexHTMLWrapper(c *gin.Context)

func IndexWrapper

func IndexWrapper(c *gin.Context)

func JSON

func JSON(theFunc APIFunc, params interface{}, c *gin.Context)

func LoadArticleComments

func LoadArticleComments(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadArticleCommentsWrapper

func LoadArticleCommentsWrapper(c *gin.Context)

func LoadAutoCompleteBoards

func LoadAutoCompleteBoards(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadAutoCompleteBoardsWrapper

func LoadAutoCompleteBoardsWrapper(c *gin.Context)

func LoadBottomArticles

func LoadBottomArticles(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadBottomArticlesWrapper

func LoadBottomArticlesWrapper(c *gin.Context)

func LoadClassBoards

func LoadClassBoards(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadClassBoardsWrapper

func LoadClassBoardsWrapper(c *gin.Context)

func LoadFavoriteBoards

func LoadFavoriteBoards(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadFavoriteBoardsWrapper

func LoadFavoriteBoardsWrapper(c *gin.Context)

func LoadGeneralArticles

func LoadGeneralArticles(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadGeneralArticlesByKeyword

func LoadGeneralArticlesByKeyword(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadGeneralArticlesWrapper

func LoadGeneralArticlesWrapper(c *gin.Context)

func LoadGeneralBoards

func LoadGeneralBoards(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadGeneralBoardsByClass

func LoadGeneralBoardsByClass(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadGeneralBoardsByClassWrapper

func LoadGeneralBoardsByClassWrapper(c *gin.Context)

func LoadGeneralBoardsWrapper

func LoadGeneralBoardsWrapper(c *gin.Context)

func LoadManArticles

func LoadManArticles(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadManArticlesWrapper

func LoadManArticlesWrapper(c *gin.Context)

func LoadPopularArticles

func LoadPopularArticles(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadPopularArticlesWrapper

func LoadPopularArticlesWrapper(c *gin.Context)

func LoadPopularBoards

func LoadPopularBoards(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadPopularBoardsWrapper

func LoadPopularBoardsWrapper(c *gin.Context)

func LoadUserArticles

func LoadUserArticles(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadUserArticlesWrapper

func LoadUserArticlesWrapper(c *gin.Context)

func LoadUserComments

func LoadUserComments(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoadUserCommentsWrapper

func LoadUserCommentsWrapper(c *gin.Context)

func Login

func Login(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LoginHTMLWrapper

func LoginHTMLWrapper(c *gin.Context)

func LoginRequiredJSON

func LoginRequiredJSON(theFunc LoginRequiredAPIFunc, params interface{}, c *gin.Context)

func LoginRequiredPathJSON

func LoginRequiredPathJSON(theFunc LoginRequiredPathAPIFunc, params interface{}, path interface{}, c *gin.Context)

func LoginRequiredPathQuery

func LoginRequiredPathQuery(theFunc LoginRequiredPathAPIFunc, params interface{}, path interface{}, c *gin.Context)

func LoginRequiredQuery

func LoginRequiredQuery(theFunc LoginRequiredAPIFunc, params interface{}, c *gin.Context)

func LoginWrapper

func LoginWrapper(c *gin.Context)

func Logout

func Logout(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func LogoutWrapper

func LogoutWrapper(c *gin.Context)

func ManArticleLockKey

func ManArticleLockKey(boardID bbs.BBoardID, articleID types.ManArticleID) (key string)

func OptionsWrapper

func OptionsWrapper(c *gin.Context)

func Query

func Query(theFunc APIFunc, params interface{}, c *gin.Context)

func RedirectPathQuery

func RedirectPathQuery(theFunc RedirectPathAPIFunc, params interface{}, path interface{}, c *gin.Context)

func Refresh

func Refresh(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func RefreshWrapper

func RefreshWrapper(c *gin.Context)

func RegisterClient

func RegisterClient(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func RegisterClientWrapper

func RegisterClientWrapper(c *gin.Context)

func RegisterHTMLWrapper

func RegisterHTMLWrapper(c *gin.Context)

func RegisterUser

func RegisterUser(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func RegisterUserWrapper

func RegisterUserWrapper(c *gin.Context)

func ReplyComments

func ReplyComments(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func ReplyCommentsWrapper

func ReplyCommentsWrapper(c *gin.Context)

func SetIDEmail

func SetIDEmail(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

func SetIDEmailWrapper

func SetIDEmailWrapper(c *gin.Context)

func SetIsTest

func SetIsTest()

func TryGetArticleContentInfo

func TryGetArticleContentInfo(userID bbs.UUserID, bboardID bbs.BBoardID, articleID bbs.ArticleID, c *gin.Context, isSystem bool, isHash bool, isContent bool) (content [][]*types.Rune, contentPrefix [][]*types.Rune, contentMD5 string, ip string, host string, bbs string, signatureMD5 string, signatureDBCS []byte, articleDetailSummary *schema.ArticleDetailSummary, fileSize int, hash cmsys.Fnv64_t, statusCode int, err error)

TryGetArticleContentInfo

嘗試拿到 article-content

  1. 根據 article-id 得到相對應的 filename, ownerid, create-time.
  2. 嘗試從 schema 拿到 db summary 資訊. (create-time)
  3. 如果可以從 schema 拿到 db 資訊: 3.1. 如果已經 deleted: return deleted. 3.2. 如果距離上次跟 pttbbs 拿的時間太近: 從 schema 拿到 content, return schema-content.
  4. 嘗試做 lock. 4.1. 如果 lock 失敗: 從 schema 拿到 content, return schema-content.
  5. 從 pttbbs 拿到 article
  6. 如果從 pttbbs 拿到的時間比 schema 裡拿到的時間舊的話: return schema-content.
  7. parse article 為 content / comments.
  8. 將 comments parse 為 firstComments / theRestComments.
  9. 將 theRestComments 丟進 queue 裡.

func TryGetManArticleContentInfo

func TryGetManArticleContentInfo(userID bbs.UUserID, bboardID bbs.BBoardID, articleID types.ManArticleID, c *gin.Context, isSystem bool, isContent bool) (content [][]*types.Rune, contentMD5 string, articleDetailSummary *schema.ManArticleDetailSummary, err error)

func UnsetIsTest

func UnsetIsTest()

func UpdateArticleContentInfo

func UpdateArticleContentInfo(
	boardID bbs.BBoardID,
	articleID bbs.ArticleID,
	content [][]*types.Rune,
	contentPrefix [][]*types.Rune,
	contentMD5 string,
	ip string,
	host string,
	bbs string,
	signatureMD5 string,
	signatureDBCS []byte,
	updateNanoTS types.NanoTS,
) (err error)

func UpdateManArticleContentInfo

func UpdateManArticleContentInfo(
	boardID bbs.BBoardID,
	articleID types.ManArticleID,
	content [][]*types.Rune,
	contentMD5 string,
	updateNanoTS types.NanoTS,
) (err error)

func UserAttemptChangeEmailHTMLWrapper

func UserAttemptChangeEmailHTMLWrapper(c *gin.Context)

func UserAttemptSetIDEmailHTMLWrapper

func UserAttemptSetIDEmailHTMLWrapper(c *gin.Context)

func UserChangeEmailHTMLWrapper

func UserChangeEmailHTMLWrapper(c *gin.Context)

func UserChangePasswdHTMLWrapper

func UserChangePasswdHTMLWrapper(c *gin.Context)

func UserHTMLWrapper

func UserHTMLWrapper(c *gin.Context)

func UserSetIDEmailHTMLWrapper

func UserSetIDEmailHTMLWrapper(c *gin.Context)

Types

type APIFunc

type APIFunc func(remoteAddr string, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

type AddFavoriteBoardParams

type AddFavoriteBoardParams struct {
	LevelIdx schema.LevelIdx   `json:"level_idx,omitempty" form:"level_idx,omitempty" url:"level_idx,omitempty"`
	FBoardID apitypes.FBoardID `json:"bid" form:"bid" url:"bid"`
}

type AddFavoriteBoardPath

type AddFavoriteBoardPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type AddFavoriteFolderParams

type AddFavoriteFolderParams struct {
	LevelIdx schema.LevelIdx `json:"level_idx,omitempty" form:"level_idx,omitempty" url:"level_idx,omitempty"`
	Title    string          `json:"title,omitempty" form:"title,omitempty" url:"title,omitempty"`
}

type AddFavoriteFolderPath

type AddFavoriteFolderPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type AddFavoriteLineParams

type AddFavoriteLineParams struct {
	LevelIdx schema.LevelIdx `json:"level_idx,omitempty" form:"level_idx,omitempty" url:"level_idx,omitempty"`
}

type AddFavoriteLinePath

type AddFavoriteLinePath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type AddFavoriteResult

type AddFavoriteResult *apitypes.BoardSummary

type AttemptChangeEmailParams

type AttemptChangeEmailParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	Password string `json:"password" form:"password"`
	Email    string `json:"email" form:"email"`
}

type AttemptChangeEmailPath

type AttemptChangeEmailPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type AttemptChangeEmailResult

type AttemptChangeEmailResult struct {
	UserID    bbs.UUserID `json:"user_id"`
	Email     string      `json:"email"`
	TokenUser bbs.UUserID `json:"tokenuser"`
}

type AttemptRegisterUserParams

type AttemptRegisterUserParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	Username string `json:"username" form:"username"`
	Email    string `json:"email" form:"email"`
}

type AttemptRegisterUserResult

type AttemptRegisterUserResult struct {
	Username string `json:"user_id"`
}

type AttemptSetIDEmailParams

type AttemptSetIDEmailParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	Password string `json:"password" form:"password"`
	Email    string `json:"email"`
}

type AttemptSetIDEmailPath

type AttemptSetIDEmailPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type AttemptSetIDEmailResult

type AttemptSetIDEmailResult struct {
	UserID bbs.UUserID `json:"user_id"`
	Email  string      `json:"email"`

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

type ChangeEmailParams

type ChangeEmailParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`
	Jwt          string `json:"token" form:"token" url:"token"`
}

type ChangeEmailPath

type ChangeEmailPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type ChangeEmailResult

type ChangeEmailResult struct {
	Email string `json:"email"`

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

type ChangePasswdParams

type ChangePasswdParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	OrigPassword    string `json:"orig_password" form:"orig_password"`
	Password        string `json:"password" form:"password"`
	PasswordConfirm string `json:"password_confirm" form:"password_confirm"`
}

type ChangePasswdPath

type ChangePasswdPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type ChangePasswdResult

type ChangePasswdResult LoginResult

func NewChangePasswdResult

func NewChangePasswdResult(result_b *pttbbsapi.ChangePasswdResult) *ChangePasswdResult

type CheckExistsUserParams

type CheckExistsUserParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	Username string `json:"username" form:"username"`
}

type CheckExistsUserResult

type CheckExistsUserResult struct {
	IsExists bool `json:"is_exists"`
}

type ClientInfo

type ClientInfo struct {
	ClientID   string           `json:"c"`
	ClientType types.ClientType `json:"t"`
}

type CooldownLimit added in v0.36.0

type CooldownLimit struct {
	NUser    int
	Posttime int
}

type CreateArticleParams

type CreateArticleParams struct {
	PostType string          `json:"class" form:"class" url:"class"`
	Title    string          `json:"title" form:"title" url:"title"`
	Content  [][]*types.Rune `json:"content" form:"content" url:"content"`
}

type CreateArticlePath

type CreateArticlePath struct {
	FBoardID apitypes.FBoardID `uri:"bid" binding:"required"`
}

type CreateArticleResult

type CreateArticleResult *apitypes.ArticleSummary

type CreateBoardParams

type CreateBoardParams struct {
	Brdname      string            `json:"brdname" form:"brdname" url:"brdname"`
	BrdClass     string            `json:"class" form:"class" url:"class"`
	BrdTitle     string            `json:"title" form:"title" url:"title"`
	BMs          []bbs.UUserID     `json:"bms,omitempty" form:"bms,omitempty" url:"bms,omitempty"`
	BrdAttr      ptttype.BrdAttr   `json:"brdattr,omitempty" form:"brdattr,omitempty" url:"brdattr,omitempty"`
	Level        ptttype.PERM      `json:"level,omitempty" form:"level,omitempty" url:"level,omitempty"`
	ChessCountry ptttype.ChessCode `json:"chess_country,omitempty" form:"chess_country,omitempty" url:"chess_country,omitempty"`
	IsGroup      bool              `json:"is_group,omitempty" form:"is_group,omitempty" url:"is_group,omitempty"`
}

type CreateBoardPath

type CreateBoardPath struct {
	ClsBid ptttype.Bid `uri:"cls" binding:"required"`
}

type CreateBoardResult

type CreateBoardResult *apitypes.BoardSummary

type CreateCommentParams

type CreateCommentParams struct {
	CommentType ptttype.CommentType `json:"type" form:"type" url:"type"`
	Content     string              `json:"content" form:"content" url:"content"`
}

type CreateCommentPath

type CreateCommentPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid" binding:"required"`
	FArticleID apitypes.FArticleID `uri:"aid" binding:"required"`
}

type CreateCommentResult

type CreateCommentResult *apitypes.Comment

type CreateRankParams

type CreateRankParams struct {
	Rank int `json:"rank" form:"rank" url:"rank"`
}

type CreateRankPath

type CreateRankPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid" binding:"required"`
	FArticleID apitypes.FArticleID `uri:"aid" binding:"required"`
}

type CreateRankResult

type CreateRankResult struct {
	Rank int `json:"rank"`

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

type CrossPostParams

type CrossPostParams struct {
	XBoardID apitypes.FBoardID `json:"xbid" form:"xbid" url:"xbid"`
}

type CrossPostPath

type CrossPostPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid" binding:"required"`
	FArticleID apitypes.FArticleID `uri:"aid" binding:"required"`
}

type CrossPostResult

type CrossPostResult struct {
	Article *apitypes.ArticleSummary `json:"article"`
	Comment *apitypes.Comment        `json:"comment"`

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

type DeleteArticlesParams

type DeleteArticlesParams struct {
	ArticleIDs []apitypes.FArticleID `json:"aids" form:"aids" url:"aids" binding:"required"`
}

type DeleteArticlesPath

type DeleteArticlesPath struct {
	FBoardID apitypes.FBoardID `uri:"bid"`
}

type DeleteArticlesResult

type DeleteArticlesResult struct {
	Success   bool        `json:"success"`
	TokenUser bbs.UUserID `json:"tokenuser"`
}

type DeleteCommentsParams

type DeleteCommentsParams struct {
	TheList []*apitypes.DeleteCommentParams `json:"list" form:"list" url:"list"`
}

type DeleteCommentsPath

type DeleteCommentsPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type DeleteCommentsResult

type DeleteCommentsResult struct {
	Success   bool        `json:"success"`
	TokenUser bbs.UUserID `json:"tokenuser"`
}

type DeleteFavoriteParams

type DeleteFavoriteParams struct {
	LevelIdx schema.LevelIdx `json:"level_idx,omitempty" form:"level_idx,omitempty" url:"level_idx,omitempty"`
	Idx      string          `json:"idx,omitempty" form:"idx,omitempty" url:"idx,omitempty"`
}

type DeleteFavoritePath

type DeleteFavoritePath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type DeleteFavoriteResult

type DeleteFavoriteResult struct {
	Success   bool        `json:"success"`
	TokenUser bbs.UUserID `json:"tokenuser"`
}

type EditArticleParams

type EditArticleParams struct {
	PostType string          `json:"class" form:"class" url:"class"`
	Title    string          `json:"title" form:"title" url:"title"`
	Content  [][]*types.Rune `json:"content" form:"content" url:"content"`
}

type EditArticlePath

type EditArticlePath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type EditArticleResult

type EditArticleResult struct {
	MTime         types.Time8     `json:"modified"` //
	Content       [][]*types.Rune `json:"content"`
	ContentPrefix [][]*types.Rune `json:"prefix"`
	Title         string          `json:"title"` //
	Class         string          `json:"class"` // can be: R: 轉, [class]
	TokenUser     bbs.UUserID     `json:"tokenuser"`
}

type GetArticleBlocksParams

type GetArticleBlocksParams struct {
	StartIdx string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Max      int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewGetArticleBlocksParams

func NewGetArticleBlocksParams() *GetArticleBlocksParams

type GetArticleBlocksPath

type GetArticleBlocksPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type GetArticleBlocksResult

type GetArticleBlocksResult struct {
	Content [][]*types.Rune `json:"content,omitempty"`

	IsDeleted  bool             `json:"deleted,omitempty"`     //
	CreateTime types.Time8      `json:"create_time,omitempty"` //
	MTime      types.Time8      `json:"modified,omitempty"`    //
	Recommend  int              `json:"recommend,omitempty"`   //
	NComments  int              `json:"n_comments,omitempty"`  //
	Owner      bbs.UUserID      `json:"owner,omitempty"`       //
	Nickname   string           `json:"nickname,omitempty"`
	Title      string           `json:"title,omitempty"` //
	Money      int              `json:"money,omitempty"` //
	Class      string           `json:"class,omitempty"` // can be: R: 轉, [class]
	Filemode   ptttype.FileMode `json:"mode,omitempty"`  //

	IP   string `json:"ip,omitempty"`
	Host string `json:"host,omitempty"` // ip 的中文呈現, 外國則為國家.
	BBS  string `json:"bbs,omitempty"`

	Rank int `json:"rank,omitempty"` // 評價

	NextIdx string `json:"next_idx"`

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

type GetArticleDetailParams

type GetArticleDetailParams struct{}

type GetArticleDetailPath

type GetArticleDetailPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type GetArticleDetailResult

type GetArticleDetailResult struct {
	BBoardID   apitypes.FBoardID   `json:"bid"`         //
	ArticleID  apitypes.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"`       //
	Nickname   string              `json:"nickname"`
	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"` //

	Brdname string `json:"brdname"`

	Content       [][]*types.Rune `json:"content"`
	ContentPrefix [][]*types.Rune `json:"prefix"`

	IP   string `json:"ip"`
	Host string `json:"host"` // ip 的中文呈現, 外國則為國家.
	BBS  string `json:"bbs"`

	Rank int `json:"rank"` // 評價

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

type GetBoardDetailParams

type GetBoardDetailParams struct {
	Fields string `json:"fields,omitempty" form:"fields,omitempty" uri:"fields,omitempty"`
}

type GetBoardDetailPath

type GetBoardDetailPath struct {
	FBoardID apitypes.FBoardID `uri:"bid"`
}

type GetBoardDetailResult

type GetBoardDetailResult *apitypes.BoardDetail

type GetBoardSummaryParams

type GetBoardSummaryParams struct{}

type GetBoardSummaryPath

type GetBoardSummaryPath struct {
	FBoardID apitypes.FBoardID `uri:"bid"`
}

type GetBoardSummaryResult

type GetBoardSummaryResult *apitypes.BoardSummary

type GetManArticleBlocksParams

type GetManArticleBlocksParams struct {
	StartIdx string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Max      int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewGetManArticleBlocksParams

func NewGetManArticleBlocksParams() *GetManArticleBlocksParams

type GetManArticleBlocksPath

type GetManArticleBlocksPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type GetManArticleBlocksResult

type GetManArticleBlocksResult struct {
	Content [][]*types.Rune `json:"content,omitempty"`

	IsDeleted  bool        `json:"deleted,omitempty"`     //
	CreateTime types.Time8 `json:"create_time,omitempty"` //
	MTime      types.Time8 `json:"modified,omitempty"`    //
	Title      string      `json:"title,omitempty"`       //

	NextIdx string `json:"next_idx"`

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

type GetManArticleDetailPath

type GetManArticleDetailPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type GetManArticleDetailResult

type GetManArticleDetailResult struct {
	BBoardID   apitypes.FBoardID   `json:"bid"` //
	ArticleID  apitypes.FArticleID `json:"aid"` //
	LevelIdx   apitypes.FArticleID `json:"level_idx"`
	IsDeleted  bool                `json:"deleted"`     //
	CreateTime types.Time8         `json:"create_time"` //
	MTime      types.Time8         `json:"modified"`    //
	Title      string              `json:"title"`       //
	IsDir      bool                `json:"is_dir"`

	Content [][]*types.Rune `json:"content"`

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

type GetUserIDResult

type GetUserIDResult struct {
	UserID bbs.UUserID `json:"user_id"`

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

type GetUserInfoParams

type GetUserInfoParams struct {
	Fields string `json:"fields,omitempty" form:"fields,omitempty" url:"fields,omitempty"`
}

type GetUserInfoPath

type GetUserInfoPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type GetUserInfoResult

type GetUserInfoResult struct {
	UserID   bbs.UUserID `json:"user_id"`
	Username string      `json:"username"`
	Realname string      `json:"realtime"`
	Nickname string      `json:"nickname"`

	Uflag        ptttype.UFlag `json:"flag"`
	Userlevel    ptttype.PERM  `json:"perm"`
	Numlogindays int           `json:"login_days"`
	Numposts     int           `json:"posts"`
	Firstlogin   types.Time8   `json:"first_login"`
	Lastlogin    types.Time8   `json:"last_login"`
	LastIP       string        `json:"last_ip"`
	LastHost     string        `json:"last_host"` // ip 的中文呈現, 外國則為國家.

	Money    int    `json:"money"`
	PttEmail string `json:"pttemail"`
	Justify  string `json:"justify"`
	Over18   bool   `json:"over18"`

	PagerUIType uint8             `json:"pager_ui"` /* 呼叫器界面類別 (was: WATER_*) */
	Pager       ptttype.PagerMode `json:"pager"`    /* 呼叫器狀態 */
	Invisible   bool              `json:"invisible"`
	Exmailbox   uint32            `json:"exmail"`

	Career        string      `json:"career"`
	Role          uint32      `json:"role"`
	LastSeen      types.Time8 `json:"last_seen"`
	TimeSetAngel  types.Time8 `json:"time_set_angel"`
	TimePlayAngel types.Time8 `json:"time_play_angel"`

	LastSong  types.Time8 `json:"last_song"`
	LoginView uint32      `json:"login_view"`

	Vlcount        int `json:"violation"`
	FiveWin        int `json:"five_win"`
	FiveLose       int `json:"five_lose"`
	FiveTie        int `json:"five_tie"`
	ChcWin         int `json:"chc_win"`
	ChcLose        int `json:"chc_lose"`
	ChcTie         int `json:"chc_tie"`
	Conn6Win       int `json:"conn6_win"`
	Conn6Lose      int `json:"conn6_lose"`
	Conn6Tie       int `json:"conn6_tie"`
	GoWin          int `json:"go_win"`
	GoLose         int `json:"go_lose"`
	GoTie          int `json:"go_tie"`
	DarkWin        int `json:"dark_win"`
	DarkLose       int `json:"dark_lose"`
	DarkTie        int `json:"dark_tie"`   /* 暗棋戰績 和 */
	ChessEloRating int `json:"chess_rank"` /* 象棋等級 */

	UaVersion uint8 `json:"ua_version"`

	Signature uint8       `json:"signaure"` /* 慣用簽名檔 */
	BadPost   int         `json:"bad_post"` /* 評價為壞文章數 */
	MyAngel   bbs.UUserID `json:"angel"`    /* 我的小天使 */

	TimeRemoveBadPost types.Time8 `json:"time_remove_bad_post"`
	TimeViolateLaw    types.Time8 `json:"time_violate_law"`

	IsDeleted bool        `json:"deleted"`
	UpdateTS  types.Time8 `json:"update_ts"`

	UserLevel2 ptttype.PERM2 `bson:"perm2"`
	UpdateTS2  types.Time8   `bson:"update_ts2"`

	Avatar   []byte      `json:"avatar"`
	AvatarTS types.Time8 `json:"avatar_ts"`

	Email    string      `json:"email"`
	EmailSet bool        `json:"email_set"`
	EmailTS  types.Time8 `json:"email_ts"`

	TwoFactorEnabled   bool        `json:"twofactor_enabled"`
	TwoFactorEnabledTS types.Time8 `json:"twofactor_enabled_ts"`

	IDEmail    string      `json:"idemail"`
	IDEmailSet bool        `json:"idemail_set"`
	IDEmailTS  types.Time8 `json:"idemail_ts"`

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

func NewUserInfoResult

func NewUserInfoResult(userDetail_db *schema.UserDetail, userNewInfo_db *schema.UserNewInfo, userIDEmail_db *schema.UserIDEmail, userEmail_db *schema.UserEmail, userPermInfo *schema.UserPermInfo) (result *GetUserInfoResult)

type GetUserVisitCountResult

type GetUserVisitCountResult struct {
	Total int64 `json:"total"`

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

type GetVersionResult

type GetVersionResult struct {
	Version    string `json:"version"`
	GitVersion string `json:"commit"`

	PttVersion    string `json:"pttversion"`
	PttGitVersion string `json:"pttcommit"`
}

type HTMLPath

type HTMLPath struct {
	Path string `uri:"path"`
}

type IndexParams

type IndexParams struct {
	In int `form:"in,omitempty"`
}

func NewIndexParams

func NewIndexParams() *IndexParams

type IndexResult

type IndexResult struct {
	Data interface{}
}

type LoadArticleCommentsParams

type LoadArticleCommentsParams struct {
	StartIdx   string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Descending bool   `json:"desc,omitempty"  form:"desc,omitempty" url:"desc,omitempty"`
	Max        int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewLoadArticleCommentsParams

func NewLoadArticleCommentsParams() *LoadArticleCommentsParams

type LoadArticleCommentsPath

type LoadArticleCommentsPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type LoadArticleCommentsResult

type LoadArticleCommentsResult struct {
	List    []*apitypes.Comment `json:"list"`
	NextIdx string              `json:"next_idx"`

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

func NewLoadArticleCommentsResult

func NewLoadArticleCommentsResult(comments_db []*schema.Comment, nextComment *schema.Comment, userID bbs.UUserID) (result *LoadArticleCommentsResult)

type LoadAutoCompleteBoardsParams

type LoadAutoCompleteBoardsParams struct {
	Keyword   string `json:"brdname,omitempty" form:"brdname,omitempty" url:"brdname,omitempty"`
	StartIdx  string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Ascending bool   `json:"asc,omitempty"  form:"asc,omitempty" url:"asc,omitempty"`
	Max       int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewLoadAutoCompleteBoardsParams

func NewLoadAutoCompleteBoardsParams() *LoadAutoCompleteBoardsParams

type LoadBottomArticlesPath

type LoadBottomArticlesPath struct {
	FBoardID apitypes.FBoardID `uri:"bid"`
}

type LoadBottomArticlesResult

type LoadBottomArticlesResult struct {
	List []*apitypes.ArticleSummary `json:"list"`

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

func NewLoadBottomArticlesResult

func NewLoadBottomArticlesResult(a_db []*schema.ArticleSummary, userReadArticleMap map[bbs.ArticleID]bool, articlePermEditableMap map[bbs.ArticleID]error, articlePermDeletableMap map[bbs.ArticleID]error, userID bbs.UUserID) *LoadBottomArticlesResult

type LoadClassBoardsParams

type LoadClassBoardsParams struct {
	StartIdx string          `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	SortBy   ptttype.BSortBy `json:"sortby,omitempty" form:"sortby,omitempty" url:"sortby,omitempty"`

	Ascending bool `json:"asc,omitempty"  form:"asc,omitempty" url:"asc,omitempty"`
	Max       int  `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewLoadClassBoardsParams

func NewLoadClassBoardsParams() *LoadClassBoardsParams

type LoadClassBoardsPath

type LoadClassBoardsPath struct {
	ClsID ptttype.Bid `uri:"clsid"`
}

type LoadClassBoardsResult

type LoadClassBoardsResult struct {
	List    []*apitypes.BoardSummary `json:"list"`
	NextIdx string                   `json:"next_idx"`

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

func NewLoadClassBoardsResult

func NewLoadClassBoardsResult(boardSummaries_db []*schema.BoardSummary, userBoardInfoMap map[bbs.BBoardID]*apitypes.UserBoardInfo, nextIdx string, sortBy ptttype.BSortBy, userID bbs.UUserID) (ret *LoadClassBoardsResult)

type LoadFavoriteBoardsParams

type LoadFavoriteBoardsParams struct {
	LevelIdx  schema.LevelIdx `json:"level_idx,omitempty" form:"level_idx,omitempty" url:"level_idx,omitempty"`
	StartIdx  string          `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Ascending bool            `json:"asc,omitempty"  form:"asc,omitempty" url:"asc,omitempty"`
	Max       int             `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewLoadFavoriteBoardsParams

func NewLoadFavoriteBoardsParams() *LoadFavoriteBoardsParams

type LoadFavoriteBoardsPath

type LoadFavoriteBoardsPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type LoadFavoriteBoardsResult

type LoadFavoriteBoardsResult struct {
	List    []*apitypes.BoardSummary `json:"list"`
	NextIdx string                   `json:"next_idx"`

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

func NewLoadFavoriteBoardsResult

func NewLoadFavoriteBoardsResult(userID bbs.UUserID, userFavorites_db []*schema.UserFavorites, boardSummaryMap_db map[ptttype.Bid]*schema.BoardSummary, userBoardInfoMap map[bbs.BBoardID]*apitypes.UserBoardInfo, nextIdx string) (result *LoadFavoriteBoardsResult)

type LoadGeneralArticlesParams

type LoadGeneralArticlesParams struct {
	Keyword    string `json:"title,omitempty" form:"title,omitempty" url:"title,omitempty"`
	StartIdx   string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Max        int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
	Descending bool   `json:"desc,omitempty"  form:"desc,omitempty" url:"desc,omitempty"`
}

func NewLoadGeneralArticlesParams

func NewLoadGeneralArticlesParams() *LoadGeneralArticlesParams

type LoadGeneralArticlesPath

type LoadGeneralArticlesPath struct {
	FBoardID apitypes.FBoardID `uri:"bid"`
}

type LoadGeneralArticlesResult

type LoadGeneralArticlesResult struct {
	List    []*apitypes.ArticleSummary `json:"list"`
	NextIdx string                     `json:"next_idx"`

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

func NewLoadGeneralArticlesResult

func NewLoadGeneralArticlesResult(a_db []*schema.ArticleSummary, userReadArticleMap map[bbs.ArticleID]bool, articlePermEditableMap map[bbs.ArticleID]error, articlePermDeletableMap map[bbs.ArticleID]error, nextIdx string, userID bbs.UUserID) *LoadGeneralArticlesResult

type LoadGeneralBoardsParams

type LoadGeneralBoardsParams struct {
	Title     string `json:"title,omitempty" form:"title,omitempty" url:"title,omitempty"`
	Keyword   string `json:"keyword,omitempty" form:"keyword,omitempty" url:"keyword,omitempty"`
	StartIdx  string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Ascending bool   `json:"asc,omitempty"  form:"asc,omitempty" url:"asc,omitempty"`
	Max       int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewLoadGeneralBoardsParams

func NewLoadGeneralBoardsParams() *LoadGeneralBoardsParams

type LoadGeneralBoardsResult

type LoadGeneralBoardsResult struct {
	List    []*apitypes.BoardSummary `json:"list"`
	NextIdx string                   `json:"next_idx"`

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

func NewLoadGeneralBoardsResult

func NewLoadGeneralBoardsResult(boardSummaries_db []*schema.BoardSummary, userBoardInfoMap map[bbs.BBoardID]*apitypes.UserBoardInfo, nextIdx string, url string, userID bbs.UUserID) *LoadGeneralBoardsResult

type LoadManArticlesParams

type LoadManArticlesParams struct {
	LevelIdx apitypes.FArticleID `json:"level_idx,omitempty" form:"level_idx,omitempty" url:"level_idx,omitempty"`
}

type LoadManArticlesPath

type LoadManArticlesPath struct {
	FBoardID apitypes.FBoardID `uri:"bid"`
}

type LoadManArticlesResult

type LoadManArticlesResult struct {
	List []*apitypes.ManArticleSummary `json:"list"`

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

func NewLoadManArticlesResult

func NewLoadManArticlesResult(articleSummaries_db []*schema.ManArticleSummary, userID bbs.UUserID) (r *LoadManArticlesResult)

type LoadPopularArticlesParams

type LoadPopularArticlesParams struct {
	StartIdx   string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Max        int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
	Descending bool   `json:"desc,omitempty"  form:"desc,omitempty" url:"desc,omitempty"`
}

func NewLoadPopularArticlesParams

func NewLoadPopularArticlesParams() *LoadPopularArticlesParams

type LoadPopularArticlesResult

type LoadPopularArticlesResult struct {
	List    []*apitypes.ArticleSummary `json:"list"`
	NextIdx string                     `json:"next_idx"`

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

type LoadPopularBoardsResult

type LoadPopularBoardsResult struct {
	List []*apitypes.BoardSummary `json:"list"`

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

func NewLoadPopularBoardsResult

func NewLoadPopularBoardsResult(boardSummaries_db []*schema.BoardSummary, userBoardInfoMap map[bbs.BBoardID]*apitypes.UserBoardInfo, userID bbs.UUserID) *LoadPopularBoardsResult

type LoadUserArticlesParams

type LoadUserArticlesParams struct {
	StartIdx   string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Descending bool   `json:"desc,omitempty"  form:"desc,omitempty" url:"desc,omitempty"`
	Max        int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewUserArticlesParams

func NewUserArticlesParams() *LoadUserArticlesParams

type LoadUserArticlesPath

type LoadUserArticlesPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type LoadUserArticlesResult

type LoadUserArticlesResult struct {
	List    []*apitypes.ArticleSummary `json:"list"`
	NextIdx string                     `json:"next_idx"`

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

func NewLoadUserArticlesResult

func NewLoadUserArticlesResult(a_db []*schema.ArticleSummary, userReadBoardArticleMap map[types.BoardArticleID]bool, nextIdx string, userID bbs.UUserID) *LoadUserArticlesResult

type LoadUserCommentsParams

type LoadUserCommentsParams struct {
	StartIdx   string `json:"start_idx,omitempty" form:"start_idx,omitempty" url:"start_idx,omitempty"`
	Descending bool   `json:"desc,omitempty"  form:"desc,omitempty" url:"desc,omitempty"`
	Max        int    `json:"limit,omitempty" form:"limit,omitempty" url:"limit,omitempty"`
}

func NewLoadUserCommentsParams

func NewLoadUserCommentsParams() *LoadUserCommentsParams

type LoadUserCommentsPath

type LoadUserCommentsPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type LoadUserCommentsResult

type LoadUserCommentsResult struct {
	List    []*apitypes.ArticleComment `json:"list"`
	NextIdx string                     `json:"next_idx"`

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

func NewLoadUserCommentsResult

func NewLoadUserCommentsResult(
	commentSummaries_db []*schema.CommentSummary,
	articleSummaryMap map[types.BoardArticleID]*schema.ArticleSummary,
	userReadBoardArticleMap map[types.BoardArticleID]types.NanoTS,
	nextIdx string,
	userID bbs.UUserID,
) (result *LoadUserCommentsResult)

type LoginLog

type LoginLog struct {
	ClientInfo
	LoginID   string
	LoginTime types.NanoTS
	LoginIP   string
	IsSuccess bool
}

LoginLog record user login info, no matter success or not

func (*LoginLog) String

func (l *LoginLog) String() string

type LoginParams

type LoginParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	Username string `json:"username" form:"username"`
	Password string `json:"password" form:"password"`
}

func NewLoginParams

func NewLoginParams() *LoginParams

type LoginRequiredAPIFunc

type LoginRequiredAPIFunc func(remoteAddr string, userID bbs.UUserID, params interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

type LoginRequiredPathAPIFunc

type LoginRequiredPathAPIFunc func(remoteAddr string, userID bbs.UUserID, params interface{}, path interface{}, c *gin.Context) (result interface{}, statusCode int, err error)

type LoginResult

type LoginResult struct {
	UserID        bbs.UUserID `json:"user_id"`
	AccessToken   string      `json:"access_token"`
	TokenType     string      `json:"token_type"`
	RefreshToken  string      `json:"refresh_token"`
	AccessExpire  types.Time8 `json:"access_expire"`
	RefreshExpire types.Time8 `json:"refresh_expire"`

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

func NewLoginResult

func NewLoginResult(result_b *pttbbsapi.LoginResult) *LoginResult

type RedirectPathAPIFunc

type RedirectPathAPIFunc func(remoteAddr string, params interface{}, path interface{}, c *gin.Context) (redirectPath string, statusCode int)

type RefreshParams

type RefreshParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	RefreshToken string `json:"refresh_token"`
}

type RefreshResult

type RefreshResult LoginResult

type RegisterClientParams

type RegisterClientParams struct {
	ClientID   string           `json:"client_id"`
	ClientType types.ClientType `json:"client_type"`
}

func NewRegisterClientParams

func NewRegisterClientParams() *RegisterClientParams

type RegisterClientResult

type RegisterClientResult struct {
	ClientSecret string `json:"client_secret"`

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

func NewRegisterClientResult

func NewRegisterClientResult(client *schema.Client, userID bbs.UUserID) *RegisterClientResult

type RegisterUserParams

type RegisterUserParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`

	Username        string `json:"username" form:"username"`
	Password        string `json:"password" form:"password"`
	PasswordConfirm string `json:"password_confirm" form:"password_confirm"`

	TwoFactorToken string `json:"token" form:"token"`

	Over18 bool `json:"over18,omitempty" form:"over18,omitempty"`

	Email    string `json:"email" form:"email"`
	Nickname string `json:"nickname,omitempty" form:"nickname,omitempty"`
	Realname string `json:"realname,omitempty" form:"realname,omitempty"`
	Career   string `json:"career,omitempty" form:"career,omitempty"`
}

func NewRegisterUserParams

func NewRegisterUserParams() *RegisterUserParams

type RegisterUserResult

type RegisterUserResult LoginResult

func NewRegisterUserResult

func NewRegisterUserResult(result_b *pttbbsapi.RegisterResult) *RegisterUserResult

type ReplyCommentsParams

type ReplyCommentsParams struct {
	TheList []*apitypes.ReplyCommentParams `json:"list" form:"list" url:"list"`
}

type ReplyCommentsPath

type ReplyCommentsPath struct {
	FBoardID   apitypes.FBoardID   `uri:"bid"`
	FArticleID apitypes.FArticleID `uri:"aid"`
}

type ReplyCommentsResult

type ReplyCommentsResult struct {
	Success bool `json:"success"`

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

type SetIDEmailParams

type SetIDEmailParams struct {
	ClientID     string `json:"client_id" form:"client_id"`
	ClientSecret string `json:"client_secret" form:"client_secret"`
	Jwt          string `json:"token" form:"token" url:"token"`
}

type SetIDEmailPath

type SetIDEmailPath struct {
	UserID bbs.UUserID `uri:"user_id"`
}

type SetIDEmailResult

type SetIDEmailResult struct {
	Email string `json:"idemail"`

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

type UserBoardPermReadable added in v0.36.0

type UserBoardPermReadable struct {
	IsSYSOP bool

	IsPolice bool

	IsBM bool

	IsBoardFriend bool
}

func CheckUserBoardPermReadable added in v0.36.0

func CheckUserBoardPermReadable(userID bbs.UUserID, boardID bbs.BBoardID, c *gin.Context) (userBoardPerm *UserBoardPermReadable, err error)

CheckUserBoardPermReadable

https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L185

Jump to

Keyboard shortcuts

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