Documentation ¶
Index ¶
- Constants
- Variables
- func ChangeEmail(userID *ptttype.UserID_t, email *ptttype.Email_t) (err error)
- func ChangePasswd(userID *ptttype.UserID_t, origPasswd []byte, passwd []byte, ip *ptttype.IPv4_t) (err error)
- func ChangeUserLevel2(userID *ptttype.UserID_t, perm ptttype.PERM2, isSet bool) (userLevel2 ptttype.PERM2, err error)
- func CheckEmailAllowRejectLists(email string) (err error)
- func CheckModifyPerm(uid ptttype.UID, user *ptttype.UserecRaw, bid ptttype.Bid, ...) (err error)
- func CheckPasswd(userID *ptttype.UserID_t, passwd []byte, ip *ptttype.IPv4_t) (err error)
- func CheckPostPerm2(uid ptttype.UID, user *ptttype.UserecRaw, bid ptttype.Bid, ...) (err error)
- func CheckPostRestriction(user *ptttype.UserecRaw, uid ptttype.UID, board *ptttype.BoardHeaderRaw, ...) bool
- func CrossPost(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (articleSummary *ptttype.ArticleSummaryRaw, comment []byte, ...)
- func DeleteArticles(boardID *ptttype.BoardID_t, filename *ptttype.Filename_t, ...) error
- func DoPostArticle(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (summary *ptttype.ArticleSummaryRaw, err error)
- func EditPost(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (newContent []byte, mtime types.Time4, newTitle *ptttype.Title_t, err error)
- func FatalLockedUser(userID *ptttype.UserID_t) error
- func FindArticleStartIdx(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (startIdx ptttype.SortIdx, err error)
- func FindBoardAutoCompleteStartIdx(keyword []byte, isAsc bool) (startIdx ptttype.SortIdx, err error)
- func FindBoardStartIdxByClass(cls []byte, boardID *ptttype.BoardID_t, isAsc bool) (startIdx ptttype.SortIdx, err error)
- func FindBoardStartIdxByName(boardID *ptttype.BoardID_t, isAsc bool) (startIdx ptttype.SortIdx, err error)
- func FormatCommentString(user *ptttype.UserecRaw, board *ptttype.BoardHeaderRaw, ...) (comment []byte, err error)
- func GetFavorites(userID *ptttype.UserID_t, retrieveTS types.Time4) (content []byte, mtime types.Time4, err error)
- func GetUID(userID *ptttype.UserID_t) (uid ptttype.UID, err error)
- func GetUser(userID *ptttype.UserID_t) (user *ptttype.UserecRaw, err error)
- func GetUser2(userID *ptttype.UserID_t) (user *ptttype.Userec2Raw, err error)
- func GetUserLevel(userID *ptttype.UserID_t) (userLevel ptttype.PERM, err error)
- func GetUserVisitCount() int32
- func GetWebURL(board *ptttype.BoardHeaderRaw, fhdr *ptttype.FileHeaderRaw) (url string)
- func InitCurrentUser(userID *ptttype.UserID_t) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
- func InitCurrentUserByUID(uid ptttype.UID) (user *ptttype.UserecRaw, err error)
- func IsBMCache(user *ptttype.UserecRaw, uid ptttype.UID, bid ptttype.Bid) bool
- func IsBoardValidUser(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (isValid bool, err error)
- func IsFreeBoardName(boardID *ptttype.BoardID_t) bool
- func LoadAutoCompleteBoards(user *ptttype.UserecRaw, uid ptttype.UID, startIdx ptttype.SortIdx, ...) (summaries []*ptttype.BoardSummaryRaw, nextSummary *ptttype.BoardSummaryRaw, ...)
- func LoadBoardDetail(user *ptttype.UserecRaw, uid ptttype.UID, bid ptttype.Bid) (boardDetail *ptttype.BoardDetailRaw, err error)
- func LoadBoardSummary(user *ptttype.UserecRaw, uid ptttype.UID, bid ptttype.Bid) (summary *ptttype.BoardSummaryRaw, err error)
- func LoadBoardsByBids(user *ptttype.UserecRaw, uid ptttype.UID, bids []ptttype.Bid) (summaries []*ptttype.BoardSummaryRaw, err error)
- func LoadBottomArticles(user *ptttype.UserecRaw, uid ptttype.UID, boardIDRaw *ptttype.BoardID_t, ...) (summaries []*ptttype.ArticleSummaryRaw, err error)
- func LoadClassBoards(user *ptttype.UserecRaw, uid ptttype.UID, classBid ptttype.Bid, ...) (summaries []*ptttype.BoardSummaryRaw, err error)
- func LoadFullClassBoards(user *ptttype.UserecRaw, uid ptttype.UID, startBid ptttype.Bid, nBoards int) (summaries []*ptttype.BoardSummaryRaw, nextSummary *ptttype.BoardSummaryRaw, ...)
- func LoadGeneralArticles(user *ptttype.UserecRaw, uid ptttype.UID, boardIDRaw *ptttype.BoardID_t, ...) (summaries []*ptttype.ArticleSummaryRaw, isNewest bool, ...)
- func LoadGeneralArticlesSameCreateTime(boardIDRaw *ptttype.BoardID_t, bid ptttype.Bid, startIdx ptttype.SortIdx, ...) (summaries []*ptttype.ArticleSummaryRaw, startNumIdx ptttype.SortIdx, ...)
- func LoadGeneralBoardDetails(user *ptttype.UserecRaw, uid ptttype.UID, startIdx ptttype.SortIdx, ...) (details []*ptttype.BoardDetailRaw, nextDetail *ptttype.BoardDetailRaw, ...)
- func LoadGeneralBoards(user *ptttype.UserecRaw, uid ptttype.UID, startIdx ptttype.SortIdx, ...) (summaries []*ptttype.BoardSummaryRaw, nextSummary *ptttype.BoardSummaryRaw, ...)
- func LoadHotBoards(user *ptttype.UserecRaw, uid ptttype.UID) (summary []*ptttype.BoardSummaryRaw, err error)
- func Login(userID *ptttype.UserID_t, passwd []byte, ip *ptttype.IPv4_t) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
- func LoginQuery(userID *ptttype.UserID_t, passwd []byte, ip *ptttype.IPv4_t) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
- func ModifyDirLite(dirFilename string, idx ptttype.SortIdx, filename *ptttype.Filename_t, ...) (err error)
- func NewBoard(user *ptttype.UserecRaw, uid ptttype.UID, clsBid ptttype.Bid, ...) (summary *ptttype.BoardSummaryRaw, err error)
- func NewPost(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (summary *ptttype.ArticleSummaryRaw, err error)
- func NewRegister(userID *ptttype.UserID_t, passwd []byte, fromHost *ptttype.IPv4_t, ...) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
- func ReadPost(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (content []byte, mtime types.Time4, hash cmsys.Fnv64_t, err error)
- func ReadPostTemplate(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (content []byte, mtime types.Time4, checksum cmsys.Fnv64_t, err error)
- func Recommend(user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, ...) (comment []byte, mtime types.Time4, err error)
- func Register(userID *ptttype.UserID_t, passwd []byte, fromHost *ptttype.IPv4_t, ...) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
- func SetUserPerm(userec *ptttype.UserecRaw, setUID ptttype.UID, setUserec *ptttype.UserecRaw, ...) (newPerm ptttype.PERM, err error)
- func SetupNewUser(user *ptttype.UserecRaw) error
- func StripANSIMoveCmd(line []byte) (newLine []byte)
- func WriteFavorites(userID *ptttype.UserID_t, content []byte) (mtime types.Time4, err error)
- func WriteFile(fpath string, flags ptttype.EditFlag, isSaveHeader bool, isUseAnony bool, ...) (entropy int, err error)
- type PostLog
Constants ¶
const ( // https://github.com/ptt/pttbbs/blob/master/mbbsd/acl.c BAKUMAN_OBJECT_TYPE_USER = "u" BAKUMAN_OBJECT_TYPE_BOARD = "b" )
const (
DO_ADD_RECOMMEND_LOCK_WAIT = time.Duration(1 * time.Second)
)
const (
POSTLOG_SZ = unsafe.Sizeof(EMPTY_POSTLOG)
)
Variables ¶
var ( BAKUMAN_REASON_LEN = ptttype.BTLEN CROSS_POST_HIDDEN_BOARD = []byte("\xa1\xb0 [\xa5\xbb\xa4\xe5\xc2\xe0\xbf\xfd\xa6\xdb\xacY\xc1\xf4\xa7\xce\xac\xdd\xaaO]\n\n") CROSS_POST_BOARD_PREFIX = []byte("\xa1\xb0 [\xa5\xbb\xa4\xe5\xc2\xe0\xbf\xfd\xa6\xdb ") CROSS_POST_BOARD_INFIX = []byte(" \xac\xdd\xaaO #") CROSS_POST_BOARD_POSTFIX = []byte("]\n\n") CROSS_POST_COMMENT_PREFIX = "\xa1\xb0 \x1b[1;32m" CROSS_POST_COMMENT_INFIX = "\x1b[0;32m:\xc2\xe0\xbf\xfd\xa6\xdc" CROSS_POST_COMMENT_HIDDEN_BOARD = "\xacY\xc1\xf4\xa7\xce\xac\xdd\xaaO" CROSS_POST_COMMENT_BOARD = "\xac\xdd\xaaO" INVIS_BYTES_POST = []byte("(\xacY\xc1\xf4\xa7\xce\xac\xdd\xaaO)\n") CROSS_POST_PREFIX = []byte("[\xc2\xe0\xbf\xfd]") )
var ( ErrNotPermitted = errors.New("not permitted") ErrInvalidParams = errors.New("invalid params") ErrNewUtmp = errors.New("unable to get new utmp") // talk.go ErrNoUser = errors.New("no user") ErrTooManyMsgs = errors.New("too many msgs") ErrInvalidPID = errors.New("invalid pid") ErrInvalidEmail = errors.New("invalid email") ErrTooManyBoards = errors.New("too many boards") ErrCooldown = errors.New("cooldown") ErrReadOnly = errors.New("read only") ErrBanned = errors.New("banned") ErrPermitNoPost = errors.New("permit no post") ErrRestricted = errors.New("restricted") ErrViolateLaw = errors.New("violate law") // bbs.go ErrVoteBoard = errors.New("vote board") ErrDeleted = errors.New("deleted") ErrNotLoginOk = errors.New("not login ok") ErrInvalidBoard = errors.New("invalid board") ErrNoRecord = errors.New("no record") ErrInvalidFileHash = errors.New("invalid file hash") // read.go ErrDeleteArticleFailed = errors.New("delete article failed") )
var EMPTY_POSTLOG = PostLog{}
Functions ¶
func ChangeEmail ¶ added in v0.7.0
func ChangePasswd ¶ added in v0.6.0
func ChangePasswd(userID *ptttype.UserID_t, origPasswd []byte, passwd []byte, ip *ptttype.IPv4_t) (err error)
https://github.com/ptt/pttbbs/blob/master/mbbsd/user.c#L961 https://github.com/ptt/pttbbs/blob/master/mbbsd/user.c#L1194
func ChangeUserLevel2 ¶ added in v0.7.1
func CheckEmailAllowRejectLists ¶ added in v0.8.1
func CheckModifyPerm ¶ added in v0.14.0
func CheckPasswd ¶ added in v0.7.0
func CheckPostPerm2 ¶ added in v0.14.0
func CheckPostRestriction ¶ added in v0.16.0
func CheckPostRestriction(user *ptttype.UserecRaw, uid ptttype.UID, board *ptttype.BoardHeaderRaw, bid ptttype.Bid) bool
CheckPostRestriction
true if pass the check (can post)
func CrossPost ¶ added in v0.16.0
func CrossPost( user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, bid ptttype.Bid, filename *ptttype.Filename_t, xBoardID *ptttype.BoardID_t, xBid ptttype.Bid, filemode ptttype.FileMode, ip *ptttype.IPv4_t, from []byte) ( articleSummary *ptttype.ArticleSummaryRaw, comment []byte, commentMTime types.Time4, err error, )
func DeleteArticles ¶ added in v0.19.0
func DoPostArticle ¶ added in v0.12.0
func DoPostArticle( user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, bid ptttype.Bid, flags ptttype.EditFlag, posttype []byte, title []byte, content [][]byte, ip *ptttype.IPv4_t, from []byte) ( summary *ptttype.ArticleSummaryRaw, err error, )
DoPostArticle
func EditPost ¶ added in v0.18.0
func EditPost( user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, bid ptttype.Bid, filename *ptttype.Filename_t, posttype []byte, title []byte, content [][]byte, oldSZ int, oldsum cmsys.Fnv64_t, ip *ptttype.IPv4_t, from []byte) ( newContent []byte, mtime types.Time4, newTitle *ptttype.Title_t, err error, )
func FatalLockedUser ¶
func FindArticleStartIdx ¶ added in v0.10.0
func FindBoardAutoCompleteStartIdx ¶ added in v0.10.0
func FindBoardStartIdxByClass ¶ added in v0.10.0
func FindBoardStartIdxByName ¶ added in v0.10.0
func FormatCommentString ¶ added in v0.14.0
func GetFavorites ¶ added in v0.9.0
func GetUser2 ¶ added in v0.7.1
func GetUser2(userID *ptttype.UserID_t) (user *ptttype.Userec2Raw, err error)
func GetUserLevel ¶ added in v0.7.1
func GetUserVisitCount ¶ added in v0.19.2
func GetUserVisitCount() int32
func GetWebURL ¶ added in v0.12.0
func GetWebURL(board *ptttype.BoardHeaderRaw, fhdr *ptttype.FileHeaderRaw) (url string)
func InitCurrentUser ¶
func InitCurrentUserByUID ¶ added in v0.15.2
func IsBoardValidUser ¶ added in v0.9.5
func IsFreeBoardName ¶ added in v0.18.0
func LoadAutoCompleteBoards ¶ added in v0.10.0
func LoadAutoCompleteBoards(user *ptttype.UserecRaw, uid ptttype.UID, startIdx ptttype.SortIdx, nBoards int, keyword []byte, isAsc bool) (summaries []*ptttype.BoardSummaryRaw, nextSummary *ptttype.BoardSummaryRaw, err error)
LoadAutoCompleteBoards
Load auto-complete boards by name.
func LoadBoardDetail ¶ added in v0.18.0
func LoadBoardSummary ¶ added in v0.8.0
func LoadBoardSummary(user *ptttype.UserecRaw, uid ptttype.UID, bid ptttype.Bid) (summary *ptttype.BoardSummaryRaw, err error)
LoadBoardSummary
Load General Board Summary ¶
Params:
user uid bid
Return:
summary err
func LoadBoardsByBids ¶ added in v0.9.2
func LoadBottomArticles ¶ added in v0.15.0
func LoadClassBoards ¶ added in v0.17.0
func LoadClassBoards(user *ptttype.UserecRaw, uid ptttype.UID, classBid ptttype.Bid, bsortBy ptttype.BSortBy) (summaries []*ptttype.BoardSummaryRaw, err error)
LoadClassBoards https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L1169
func LoadFullClassBoards ¶ added in v0.17.0
func LoadFullClassBoards(user *ptttype.UserecRaw, uid ptttype.UID, startBid ptttype.Bid, nBoards int) (summaries []*ptttype.BoardSummaryRaw, nextSummary *ptttype.BoardSummaryRaw, err error)
LoadFullClassBoards
Load full class boards https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L1142
Params
user uid startIdx: the idx in bsorted. nBoards: try to get at most nBoards
Return
summaries nextIdx: next idx in bsorted. err
func LoadGeneralArticles ¶ added in v0.3.0
func LoadGeneralArticles(user *ptttype.UserecRaw, uid ptttype.UID, boardIDRaw *ptttype.BoardID_t, bid ptttype.Bid, startIdx ptttype.SortIdx, nArticles int, isDesc bool) (summaries []*ptttype.ArticleSummaryRaw, isNewest bool, nextSummary *ptttype.ArticleSummaryRaw, startNumIdx ptttype.SortIdx, err error)
LoadGeneralArticles
load general articles in descending mode.
Implementing: 1. preprocessing in i_read (perm-check, cache-preparation) 2. get_records_and_bottom (with only records) https://github.com/ptt/pttbbs/blob/master/mbbsd/read.c#L1197 https://github.com/ptt/pttbbs/blob/master/mbbsd/read.c#L1106
get bottom can be a separated api.
func LoadGeneralArticlesSameCreateTime ¶ added in v0.10.0
func LoadGeneralBoardDetails ¶ added in v0.23.0
func LoadGeneralBoardDetails(user *ptttype.UserecRaw, uid ptttype.UID, startIdx ptttype.SortIdx, nBoards int, isAsc bool, bsortBy ptttype.BSortBy) (details []*ptttype.BoardDetailRaw, nextDetail *ptttype.BoardDetailRaw, err error)
LoadGeneralBoardDetails
Load general boards by name.
https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L1142 Params:
user uid startIdx: the idx in bsorted. nBoards: try to get at most nBoards keyword
Return:
summary nextIdx: next idx in bsorted. err
func LoadGeneralBoards ¶
func LoadGeneralBoards(user *ptttype.UserecRaw, uid ptttype.UID, startIdx ptttype.SortIdx, nBoards int, title []byte, keyword []byte, isAsc bool, bsortBy ptttype.BSortBy) (summaries []*ptttype.BoardSummaryRaw, nextSummary *ptttype.BoardSummaryRaw, err error)
LoadGeneralBoards
Load general boards by name.
https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L1142 Params:
user uid startIdx: the idx in bsorted. nBoards: try to get at most nBoards keyword
Return:
summary nextIdx: next idx in bsorted. err
func LoadHotBoards ¶ added in v0.9.0
func LoadHotBoards(user *ptttype.UserecRaw, uid ptttype.UID) (summary []*ptttype.BoardSummaryRaw, err error)
LoadHotBoards
https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L1125
func Login ¶ added in v0.5.0
func Login(userID *ptttype.UserID_t, passwd []byte, ip *ptttype.IPv4_t) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
Login
adopted from the original start_client. https://github.com/ptt/pttbbs/blob/master/mbbsd/mbbsd.c#L1399
func LoginQuery ¶
func LoginQuery(userID *ptttype.UserID_t, passwd []byte, ip *ptttype.IPv4_t) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
LoginQuery
Params
userID: userID passwd: passwd ip: ip
Return
*UserecRaw: user error: err
func ModifyDirLite ¶ added in v0.14.0
func NewBoard ¶ added in v0.11.1
func NewBoard( user *ptttype.UserecRaw, uid ptttype.UID, clsBid ptttype.Bid, brdname *ptttype.BoardID_t, brdClass []byte, brdTitle []byte, BMs *ptttype.BM_t, brdAttr ptttype.BrdAttr, level ptttype.PERM, chessCountry ptttype.ChessCode, isGroup bool, ) ( summary *ptttype.BoardSummaryRaw, err error)
NewBoard
https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L2283
func NewPost ¶ added in v0.12.0
func NewPost( user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, bid ptttype.Bid, posttype []byte, title []byte, content [][]byte, ip *ptttype.IPv4_t, from []byte) ( summary *ptttype.ArticleSummaryRaw, err error, )
NewPost
func NewRegister ¶
func NewRegister( userID *ptttype.UserID_t, passwd []byte, fromHost *ptttype.IPv4_t, email *ptttype.Email_t, isEmailVerified bool, isAdbannerUSong bool, nickname *ptttype.Nickname_t, realname *ptttype.RealName_t, career *ptttype.Career_t, address *ptttype.Address_t, over18 bool, ) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
NewRegister
XXX Assuming valid input. need to verify email at api.
func ReadPost ¶ added in v0.4.0
func ReadPost( user *ptttype.UserecRaw, uid ptttype.UID, boardID *ptttype.BoardID_t, bid ptttype.Bid, filename *ptttype.Filename_t, retrieveTS types.Time4, isHash bool) ( content []byte, mtime types.Time4, hash cmsys.Fnv64_t, err error, )
ReadPost
pmore is replaced by frontend. We just need to return the whole content. We do not update brc here, because it requires lots of file-disk. require middlewares to handle user-read-article.
func ReadPostTemplate ¶ added in v0.23.3
func Register ¶ added in v0.5.0
func Register( userID *ptttype.UserID_t, passwd []byte, fromHost *ptttype.IPv4_t, email *ptttype.Email_t, isEmailVerified bool, isAdbannerUSong bool, nickname *ptttype.Nickname_t, realname *ptttype.RealName_t, career *ptttype.Career_t, address *ptttype.Address_t, over18 bool, ) (uid ptttype.UID, user *ptttype.UserecRaw, err error)
Login
adopted from the original start_client with LOGINASNEW. https://github.com/ptt/pttbbs/blob/master/mbbsd/mbbsd.c#L1399 https://github.com/ptt/pttbbs/blob/master/mbbsd/mbbsd.c#L714
func SetUserPerm ¶ added in v0.13.1
func SetUserPerm(userec *ptttype.UserecRaw, setUID ptttype.UID, setUserec *ptttype.UserecRaw, perm ptttype.PERM) (newPerm ptttype.PERM, err error)
SetUserPerm https://github.com/ptt/pttbbs/blob/master/mbbsd/user.c#L1166
func SetupNewUser ¶
func StripANSIMoveCmd ¶ added in v0.12.0
func WriteFavorites ¶ added in v0.23.6
func WriteFile ¶ added in v0.12.0
func WriteFile(fpath string, flags ptttype.EditFlag, isSaveHeader bool, isUseAnony bool, title []byte, content [][]byte, user *ptttype.UserecRaw, uid ptttype.UID, board *ptttype.BoardHeaderRaw, bid ptttype.Bid, ip *ptttype.IPv4_t, from []byte, mode ptttype.UserOpMode) (entropy int, err error)
WriteFile
https://github.com/ptt/pttbbs/blob/master/mbbsd/edit.c#L3733 https://github.com/ptt/pttbbs/blob/master/mbbsd/edit.c#L1924