content

package
v0.0.0-...-516970c Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoardOpTypeInvalid pkgservice.OpType = iota

	BoardOpTypeCreateBoard
	BoardOpTypeDeleteBoard
	BoardOpTypeMigrateBoard

	BoardOpTypeCreateTitle
	BoardOpTypeUpdateTitle

	BoardOpTypeCreateArticle
	BoardOpTypeUpdateArticle
	BoardOpTypeDeleteArticle

	BoardOpTypeCreateMedia
	BoardOpTypeDeleteMedia

	BoardOpTypeCreateComment
	BoardOpTypeDeleteComment

	BoardOpTypeCreateReply
	BoardOpTypeUpdateReply
	BoardOpTypeDeleteReply

	NBoardOpType
)
View Source
const (

	// board-oplog
	AddBoardOplogMsg pkgservice.OpType //57
	AddBoardOplogsMsg

	AddPendingBoardOplogMsg
	AddPendingBoardOplogsMsg

	SyncBoardOplogMsg
	SyncBoardOplogAckMsg
	SyncBoardOplogNewOplogsMsg
	SyncBoardOplogNewOplogsAckMsg

	InvalidSyncBoardOplogMsg

	ForceSyncBoardOplogMsg
	ForceSyncBoardOplogAckMsg
	ForceSyncBoardOplogByMerkleMsg
	ForceSyncBoardOplogByMerkleAckMsg
	ForceSyncBoardOplogByOplogAckMsg

	SyncPendingBoardOplogMsg
	SyncPendingBoardOplogAckMsg

	// sync title
	SyncCreateTitleMsg
	SyncCreateTitleAckMsg

	SyncUpdateTitleMsg
	SyncUpdateTitleAckMsg

	ForceSyncTitleMsg
	ForceSyncTitleAckMsg

	// sync article
	SyncCreateArticleMsg
	SyncCreateArticleAckMsg
	SyncCreateArticleBlockMsg
	SyncCreateArticleBlockAckMsg

	SyncUpdateArticleMsg
	SyncUpdateArticleAckMsg
	SyncUpdateArticleBlockMsg
	SyncUpdateArticleBlockAckMsg

	ForceSyncArticleMsg
	ForceSyncArticleAckMsg

	// sync comment
	SyncCreateCommentMsg
	SyncCreateCommentAckMsg
	SyncCreateCommentBlockMsg
	SyncCreateCommentBlockAckMsg

	ForceSyncCommentMsg
	ForceSyncCommentAckMsg

	ForceSyncArticleCommentMsg

	// sync media
	SyncCreateMediaMsg
	SyncCreateMediaAckMsg
	SyncCreateMediaBlockMsg
	SyncCreateMediaBlockAckMsg

	ForceSyncMediaMsg
	ForceSyncMediaAckMsg
)

protocol

View Source
const (
	MaxSyncRandomSeconds = 30
	MinSyncRandomSeconds = 15
)

sync

View Source
const (
	MaxUploadImageSize   = 10485760 // 10MB
	MaxUploadImageWidth  = 8192
	MaxUploadImageHeight = 8192
)

image

View Source
const (
	MaxMasters = 1
)

max-masters

View Source
const (
	NFirstLineInBlock = 1
)

article

View Source
const (
	PCommentCount = 12
)

count

Variables

View Source
var (
	ErrInvalidBoard = errors.New("invalid board")

	ErrNotFound = errors.New("not found")

	ErrInvalidBlock = errors.New("invalid block")

	ErrOutdated = errors.New("outdated")

	ErrInvalidOP = errors.New("invalid op")

	ErrInvalidTitleLength = errors.New("invalid title length")
)
View Source
var (
	DBBoardIdxOplogPrefix    = []byte(".bdig")
	DBBoardOplogPrefix       = []byte(".bdlg")
	DBBoardMerkleOplogPrefix = []byte(".bdmk")

	DBBoardPrefix                  = []byte(".bddb")
	DBBoardIdxPrefix               = []byte(".bdix")
	DBBoardIdx2Prefix              = []byte(".bdi2")
	DBBoardLastSeenPrefix          = []byte(".bdls")
	DBBoardArticleCreateTSPrefix   = []byte(".bdac")
	DBBoardCommentCreateTSPrefix   = []byte(".bdcc")
	DBArticlePrefix                = []byte(".aldb")
	DBArticleIdxPrefix             = []byte(".alix")
	DBArticleLastSeenPrefix        = []byte(".alls")
	DBArticleCommentCreateTSPrefix = []byte(".alcc")
	DBPushPrefix                   = []byte(".alps")
	DBBooPrefix                    = []byte(".albo")
	DBCommentPrefix                = []byte(".ctdb")
	DBCommentIdxPrefix             = []byte(".ctix")
	DBReplyPrefix                  = []byte(".rpdb")
	DBReplyIdxPrefix               = []byte(".rpix")
	DBImagePrefix                  = []byte(".imdb")
	DBImageIdxPrefix               = []byte(".imix")
	DBMediaPrefix                  = []byte(".madb")
	DBMediaIdxPrefix               = []byte(".maix")
	DBTitlePrefix                  = []byte(".tldb")
	DBTitleIdxPrefix               = []byte(".tlix")
)

db

View Source
var (
	RenewOpKeySeconds  int64 = 86400
	ExpireOpKeySeconds int64 = 259200
)

op-key

View Source
var (
	DBFix237Prefix = []byte(".f056") // 237 in base58
)

fix

View Source
var (
	DefaultConfig = Config{
		DataDir:     filepath.Join(node.DefaultDataDir(), "content"),
		KeystoreDir: filepath.Join(node.DefaultDataDir(), ".keyContent"),
	}
)

config

View Source
var (
	DefaultDeletedComment = [][]byte{
		[]byte("(本文已被刪除)"),
	}
)

comment

Functions

func ArticlesToObjs

func ArticlesToObjs(typedObjs []*Article) []pkgservice.Object

func BoardOplogsToOplogs

func BoardOplogsToOplogs(typedLogs []*BoardOplog) []*pkgservice.BaseOplog

func CommentsToObjs

func CommentsToObjs(typedObjs []*Comment) []pkgservice.Object

func DefaultTitle

func DefaultTitle(myID *types.PttID, creatorID *types.PttID, myName string) []byte

default-title

func DefaultTitleCN

func DefaultTitleCN(myID *types.PttID, creatorID *types.PttID, myName string) []byte

func DefaultTitleEN

func DefaultTitleEN(myID *types.PttID, creatorID *types.PttID, myName string) []byte

func DefaultTitleHK

func DefaultTitleHK(myID *types.PttID, creatorID *types.PttID, myName string) []byte

func DefaultTitleTW

func DefaultTitleTW(myID *types.PttID, creatorID *types.PttID, myName string) []byte

func InitContent

func InitContent(dataDir string, keystoreDir string) error

func InitLocaleInfo

func InitLocaleInfo()

func NewEmptyApproveJoinBoard

func NewEmptyApproveJoinBoard() *pkgservice.ApproveJoinEntity

func ProtocolSyncUpdateArticle

func ProtocolSyncUpdateArticle() error

func TeardownContent

func TeardownContent()

func TitlesToObjs

func TitlesToObjs(typedObjs []*Title) []pkgservice.Object

Types

type Article

type Article struct {
	*pkgservice.BaseObject `json:"b"`

	UpdateTS types.Timestamp `json:"UT"`

	SyncInfo *SyncArticleInfo `json:"s,omitempty"`

	Title []byte `json:"T,omitempty"`

	NPush *pkgservice.Count `json:"-"` // from other db-records
	NBoo  *pkgservice.Count `json:"-"` // from other db-records

	CommentCreateTS types.Timestamp `json:"-"` // from other db-records
	LastSeen        types.Timestamp `json:"-"` // from other db-records

}

func AliveArticles

func AliveArticles(typedObjs []*Article) []*Article

func NewArticle

func NewArticle(
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,

	title []byte,

) (*Article, error)

func NewEmptyArticle

func NewEmptyArticle() *Article

func ObjsToArticles

func ObjsToArticles(objs []pkgservice.Object) []*Article

func (*Article) DeleteAll

func (a *Article) DeleteAll(comment *Comment, isLocked bool) error

func (*Article) Get

func (a *Article) Get(isLocked bool) error

func (*Article) GetByID

func (a *Article) GetByID(isLocked bool) error

func (*Article) GetNewObjByID

func (a *Article) GetNewObjByID(id *types.PttID, isLocked bool) (pkgservice.Object, error)

func (*Article) GetSyncInfo

func (a *Article) GetSyncInfo() pkgservice.SyncInfo

func (*Article) GetUpdateTS

func (a *Article) GetUpdateTS() types.Timestamp

func (*Article) IncreaseComment

func (a *Article) IncreaseComment(commentID *types.PttID, commentType CommentType, ts types.Timestamp) error

func (*Article) LoadBoo

func (a *Article) LoadBoo() (*pkgservice.Count, error)

func (*Article) LoadCommentCreateTS

func (a *Article) LoadCommentCreateTS() (types.Timestamp, error)

func (*Article) LoadLastSeen

func (a *Article) LoadLastSeen() (types.Timestamp, error)

func (*Article) LoadPush

func (a *Article) LoadPush() (*pkgservice.Count, error)

func (*Article) Marshal

func (a *Article) Marshal() ([]byte, error)

func (*Article) MarshalCommentCreateTSKey

func (a *Article) MarshalCommentCreateTSKey() ([]byte, error)

func (*Article) MarshalKey

func (a *Article) MarshalKey() ([]byte, error)

func (*Article) MarshalLastSeenKey

func (a *Article) MarshalLastSeenKey() ([]byte, error)

func (*Article) NewEmptyObj

func (a *Article) NewEmptyObj() pkgservice.Object

func (*Article) Postdelete

func (a *Article) Postdelete(comment *Comment, isLocked bool) error

func (*Article) Save

func (a *Article) Save(isLocked bool) error

func (*Article) SaveCommentCreateTS

func (a *Article) SaveCommentCreateTS(ts types.Timestamp) error

func (*Article) SaveLastSeen

func (a *Article) SaveLastSeen(ts types.Timestamp) error

func (*Article) SetSyncInfo

func (a *Article) SetSyncInfo(theSyncInfo pkgservice.SyncInfo) error

func (*Article) SetUpdateTS

func (a *Article) SetUpdateTS(ts types.Timestamp)

func (*Article) Unmarshal

func (a *Article) Unmarshal(theBytes []byte) error

type ArticleBlock

type ArticleBlock struct {
	V           types.Version
	BlockInfoID *types.PttID `json:"bID"`
	ArticleID   *types.PttID `json:"AID"`
	RefID       *types.PttID `json:"ID"`
	ContentType ContentType  `json:"ct"`
	CommentType CommentType  `json:"mt"`
	BlockID     uint32       `json:"BID"`

	Status types.Status `json:"S"`

	CreateTS types.Timestamp `json:"CT"`
	UpdateTS types.Timestamp `json:"UT"`

	CreatorID *types.PttID `json:"CID"`
	UpdaterID *types.PttID `json:"UID"`

	Buf [][]byte `json:"B"`
}

func NewArticleBlock

func NewArticleBlock() (*ArticleBlock, error)

type ArticleInfo

type ArticleInfo struct {
	Op pkgservice.OpType

	ContentBlockID *types.PttID
	NBlock         int
	MediaIDs       []*types.PttID

	Log *BoardOplog
}

type Backend

type Backend struct {
	*pkgservice.BaseService
	// contains filtered or unexported fields
}

func NewBackend

func NewBackend(ctx *pkgservice.ServiceContext, cfg *Config, id *types.PttID, ptt pkgservice.Ptt, accountBackend *account.Backend) (*Backend, error)

func (*Backend) APIs

func (b *Backend) APIs() []rpc.API

func (*Backend) CreateArticle

func (b *Backend) CreateArticle(entityIDBytes []byte, title []byte, article [][]byte, mediaIDStrs []string) (*BackendCreateArticle, error)

func (*Backend) CreateBoard

func (b *Backend) CreateBoard(title []byte, isPrivate bool) (*BackendCreateBoard, error)

func (*Backend) CreateComment

func (b *Backend) CreateComment(entityIDBytes []byte, articleIDBytes []byte, commentType CommentType, commentBytes []byte, mediaIDBytes []byte) (*BackendCreateComment, error)

func (*Backend) CreateReply

func (b *Backend) CreateReply(entityIDBytes []byte, articleIDBytes []byte, commentIDBytes []byte, reply [][]byte, mediaIDBytes []byte) (*BackendCreateReply, error)

func (*Backend) DeleteArticle

func (b *Backend) DeleteArticle(entityIDBytes []byte, articleIDBytes []byte) (*BackendDeleteArticle, error)

func (*Backend) DeleteBoard

func (b *Backend) DeleteBoard(entityIDBytes []byte) (bool, error)

func (*Backend) DeleteComment

func (b *Backend) DeleteComment(entityIDBytes []byte, commentIDBytes []byte) (*BackendDeleteComment, error)

func (*Backend) DeleteMember

func (b *Backend) DeleteMember(entityIDBytes []byte, userIDBytes []byte) (bool, error)

func (*Backend) DeleteReply

func (b *Backend) DeleteReply(entityIDBytes []byte, articleIDBytes []byte, commentIDBytes []byte) (*BackendDeleteReply, error)

func (*Backend) ForceSyncBoardMerkle

func (b *Backend) ForceSyncBoardMerkle(entityIDBytes []byte) (bool, error)

func (*Backend) GetArticle

func (b *Backend) GetArticle(entityIDBytes []byte, articleIDBytes []byte) (*BackendGetArticle, error)

func (*Backend) GetArticleBlockList

func (b *Backend) GetArticleBlockList(entityIDBytes []byte, articleIDBytes []byte, subContentIDBytes []byte, contentType ContentType, blockID uint32, limit int, listOrder pttdb.ListOrder) ([]*ArticleBlock, error)

func (*Backend) GetArticleList

func (b *Backend) GetArticleList(entityIDBytes []byte, startingArticleIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*BackendGetArticle, error)

func (*Backend) GetArticleSummary

func (b *Backend) GetArticleSummary(entityIDBytes []byte, articleInfo *BackendArticleSummaryParams) (*ArticleBlock, error)

func (*Backend) GetArticleSummaryByIDs

func (b *Backend) GetArticleSummaryByIDs(entityIDBytes []byte, articleInfos []*BackendArticleSummaryParams) (map[string]*ArticleBlock, error)

func (*Backend) GetBoard

func (b *Backend) GetBoard(entityIDBytes []byte) (*BackendGetBoard, error)

func (*Backend) GetBoardList

func (b *Backend) GetBoardList(startingIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*BackendGetBoard, error)

func (*Backend) GetBoardOplogList

func (b *Backend) GetBoardOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*BoardOplog, error)

func (*Backend) GetBoardOplogMerkle

func (b *Backend) GetBoardOplogMerkle(entityIDBytes []byte) (*pkgservice.BackendMerkle, error)

func (*Backend) GetBoardOplogMerkleNodeList

func (b *Backend) GetBoardOplogMerkleNodeList(entityIDBytes []byte, level pkgservice.MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.BackendMerkleNode, error)

func (*Backend) GetFile

func (b *Backend) GetFile(entityIDBytes []byte, mediaIDBytes []byte) (*BackendGetFile, error)

func (*Backend) GetImage

func (b *Backend) GetImage(entityIDBytes []byte, mediaIDBytes []byte) (*BackendGetImg, error)

func (*Backend) GetJoinKeys

func (b *Backend) GetJoinKeys(entityIDBytes []byte) ([]*pkgservice.KeyInfo, error)

func (*Backend) GetPendingBoardOplogInternalList

func (b *Backend) GetPendingBoardOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*BoardOplog, error)

func (*Backend) GetPendingBoardOplogMasterList

func (b *Backend) GetPendingBoardOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*BoardOplog, error)

func (*Backend) GetPokedArticleList

func (b *Backend) GetPokedArticleList(boardID []byte) ([]*BackendGetArticle, error)

func (*Backend) GetRawArticle

func (b *Backend) GetRawArticle(entityIDBytes []byte, articleIDBytes []byte) (*Article, error)

func (*Backend) GetRawBoard

func (b *Backend) GetRawBoard(entityIDBytes []byte) (*Board, error)

func (*Backend) GetRawComment

func (b *Backend) GetRawComment(entityIDBytes []byte, commentIDBytes []byte) (*Comment, error)

func (*Backend) GetRawReply

func (b *Backend) GetRawReply(entityIDBytes []byte, articleIDBytes []byte, commentIDBytes []byte) (*Reply, error)

func (*Backend) GetRawTitle

func (b *Backend) GetRawTitle(entityIDBytes []byte) (*Title, error)

func (*Backend) GetRawTitleByID

func (b *Backend) GetRawTitleByID(entityID *types.PttID) (*Title, error)

func (*Backend) InviteMaster

func (b *Backend) InviteMaster(boardID []byte, userID []byte, nodeURL []byte) (*BackendInviteMaster, error)

func (*Backend) MarkArticleSeen

func (b *Backend) MarkArticleSeen(entityIDBytes []byte, articleIDBytes []byte) (types.Timestamp, error)

func (*Backend) MarkBoardSeen

func (b *Backend) MarkBoardSeen(entityIDBytes []byte) (types.Timestamp, error)

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) SetTitle

func (b *Backend) SetTitle(entityIDBytes []byte, title []byte) (*BackendGetBoard, error)

func (*Backend) ShowBoardURL

func (b *Backend) ShowBoardURL(entityIDBytes []byte) (*pkgservice.BackendJoinURL, error)

func (*Backend) Start

func (b *Backend) Start() error

func (*Backend) Stop

func (b *Backend) Stop() error

func (*Backend) TransferMaster

func (b *Backend) TransferMaster(boardID []byte, userID []byte) (*BackendRevokeMaster, error)

func (*Backend) UpdateArticle

func (b *Backend) UpdateArticle(entityIDBytes []byte, articleIDBytes []byte, article [][]byte, mediaIDStrs []string) (*BackendUpdateArticle, error)

func (*Backend) UpdateReply

func (b *Backend) UpdateReply(entityIDBytes []byte, articleIDBytes []byte, commentIDBytes []byte, reply [][]byte, mediaIDBytes []byte) (*BackendUpdateReply, error)

func (*Backend) UploadFile

func (b *Backend) UploadFile(entityIDBytes []byte, filename []byte, bytes []byte) (*BackendUploadFile, error)

func (*Backend) UploadImage

func (b *Backend) UploadImage(entityIDBytes []byte, fileType string, bytes []byte) (*BackendUploadImg, error)

type BackendArticleSummaryParams

type BackendArticleSummaryParams struct {
	ArticleID      string `json:"A"`
	ContentBlockID string `json:"B"`
}

type BackendCreateArticle

type BackendCreateArticle struct {
	BoardID        *types.PttID `json:"BID"`
	ArticleID      *types.PttID `json:"AID"`
	ContentBlockID *types.PttID `json:"cID"`
	NBlock         int          `json:"NB"`
}

type BackendCreateBoard

type BackendCreateBoard struct {
	ID        *types.PttID
	CreateTS  types.Timestamp `json:"CT"`
	UpdateTS  types.Timestamp `json:"UT"`
	CreatorID *types.PttID    `json:"CID"`
	UpdaterID *types.PttID    `json:"UID"`

	Status types.Status `json:"S"`

	Title []byte `json:"T"`

	BoardType pkgservice.EntityType `json:"BT"`
}

type BackendCreateComment

type BackendCreateComment struct {
	BoardID        *types.PttID `json:"BID"`
	ArticleID      *types.PttID `json:"AID"`
	CommentID      *types.PttID `json:"CID"`
	ContentBlockID *types.PttID `json:"cID"`
}

type BackendCreateReply

type BackendCreateReply struct {
	BoardID        *types.PttID `json:"BID"`
	ArticleID      *types.PttID `json:"AID"`
	CommentID      *types.PttID `json:"CID"`
	ReplyID        *types.PttID `json:"RID"`
	ContentBlockID *types.PttID `json:"cID"`
}

type BackendDeleteArticle

type BackendDeleteArticle struct {
}

type BackendDeleteBoard

type BackendDeleteBoard struct {
}

type BackendDeleteComment

type BackendDeleteComment struct {
}

type BackendDeleteReply

type BackendDeleteReply struct {
}

type BackendGetArticle

type BackendGetArticle struct {
	ID              *types.PttID
	CreateTS        types.Timestamp //`json:"CT"`
	UpdateTS        types.Timestamp //`json:"UT"`
	CreatorID       *types.PttID    //`json:"CID"`
	BoardID         *types.PttID    //`json:"BID"`
	ContentBlockID  *types.PttID    //`json:"cID"`
	NBlock          int             //`json:"N"`
	NPush           int             `json:"NP"`
	NBoo            int             `json:"NB"`
	Title           []byte          //`json:"T"`
	CommentCreateTS types.Timestamp `json:"c"`
	LastSeen        types.Timestamp `json:"L"`
	Status          types.Status    `json:"S"`
}

type BackendGetArticleBlock

type BackendGetArticleBlock struct {
}

type BackendGetBoard

type BackendGetBoard struct {
	ID              *types.PttID
	Title           []byte
	Status          types.Status `json:"S"`
	CreateTS        types.Timestamp
	UpdateTS        types.Timestamp
	JoinTS          types.Timestamp `json:"JT"`
	ArticleCreateTS types.Timestamp
	LastSeen        types.Timestamp
	CreatorID       *types.PttID          `json:"C"`
	BoardType       pkgservice.EntityType `json:"BT"`
}

type BackendGetFile

type BackendGetFile struct {
	ID        *types.PttID
	BoardID   *types.PttID         `json:"BID"`
	MediaType pkgservice.MediaType `json:"M"`
	Buf       []byte               `json:"B"`
}

type BackendGetImg

type BackendGetImg struct {
	ID      *types.PttID
	BoardID *types.PttID         `json:"BID"`
	Type    pkgservice.MediaType `json:"T"`
	Buf     []byte               `json:"B"`
}

type BackendInviteMaster

type BackendInviteMaster struct {
}

type BackendJoinBoard

type BackendJoinBoard struct {
}

type BackendLeaveBoard

type BackendLeaveBoard struct {
}

type BackendRevokeMaster

type BackendRevokeMaster struct {
}

type BackendShowArticleURL

type BackendShowArticleURL struct {
	ID  *types.PttID
	BID *types.PttID
	URL string
}

type BackendShowBoardURL

type BackendShowBoardURL struct {
	ID        string
	CreatorID string `json:"C"`
	Title     string `json:"T"`
	Pnode     string `json:"Pn"`
	URL       string
}

type BackendUpdateArticle

type BackendUpdateArticle struct {
	BoardID        *types.PttID `json:"BID"`
	ArticleID      *types.PttID `json:"AID"`
	ContentBlockID *types.PttID `json:"cID"`
	NBlock         int          `json:"NB"`
}

type BackendUpdateReply

type BackendUpdateReply struct {
	BoardID        *types.PttID `json:"BID"`
	ArticleID      *types.PttID `json:"AID"`
	CommentID      *types.PttID `json:"CID"`
	ReplyID        *types.PttID `json:"RID"`
	ContentBlockID *types.PttID `json:"cID"`
}

type BackendUploadFile

type BackendUploadFile struct {
	ID      *types.PttID
	BoardID *types.PttID `json:"BID"`
}

type BackendUploadImg

type BackendUploadImg struct {
	ID      *types.PttID
	BoardID *types.PttID         `json:"BID"`
	Type    pkgservice.MediaType `json:"T"`
}

type Board

type Board struct {
	*pkgservice.BaseEntity `json:"e"`

	UpdateTS types.Timestamp `json:"UT"`

	Title []byte `json:"T,omitempty"`

	// get from other dbs
	LastSeen        types.Timestamp `json:"-"`
	ArticleCreateTS types.Timestamp `json:"-"`

	BoardMerkle *pkgservice.Merkle `json:"-"`
}

func NewBoard

func NewBoard(myID *types.PttID, ts types.Timestamp, ptt pkgservice.Ptt, service pkgservice.Service, spm pkgservice.ServiceProtocolManager, dbLock *types.LockMap) (*Board, error)

func NewEmptyBoard

func NewEmptyBoard() *Board

func (*Board) GetUpdateTS

func (b *Board) GetUpdateTS() types.Timestamp

func (*Board) IdxKey

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

func (*Board) Init

func (*Board) InitPM

func (b *Board) InitPM(ptt pkgservice.Ptt, service pkgservice.Service) error

func (*Board) LoadArticleCreateTS

func (b *Board) LoadArticleCreateTS() (types.Timestamp, error)

func (*Board) LoadLastSeen

func (b *Board) LoadLastSeen() (types.Timestamp, error)

func (*Board) Marshal

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

func (*Board) MarshalArticleCreateTSKey

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

func (*Board) MarshalCommentCreateTSKey

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

func (*Board) MarshalKey

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

func (*Board) MarshalLastSeenKey

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

func (*Board) Save

func (b *Board) Save(isLocked bool) error

func (*Board) SaveArticleCreateTS

func (b *Board) SaveArticleCreateTS(ts types.Timestamp) error

func (*Board) SaveLastSeen

func (b *Board) SaveLastSeen(ts types.Timestamp) error

func (*Board) SetUpdateTS

func (b *Board) SetUpdateTS(ts types.Timestamp)

func (*Board) Unmarshal

func (b *Board) Unmarshal(theBytes []byte) error

type BoardOpCreateArticle

type BoardOpCreateArticle struct {
	BlockInfoID *types.PttID `json:"BID"`
	Hashs       [][][]byte   `json:"H"`
	NBlock      int          `json:"NB"`

	MediaIDs []*types.PttID `json:"ms,omitempty"`

	TitleHash []byte `json:"th"`
}

type BoardOpCreateBoard

type BoardOpCreateBoard struct {
	Title []byte `json:"t"`
}

type BoardOpCreateComment

type BoardOpCreateComment struct {
	ArticleID *types.PttID `json:"AID"`

	BlockInfoID *types.PttID   `json:"BID"`
	Hashs       [][][]byte     `json:"H"`
	MediaIDs    []*types.PttID `json:"ms,omitempty"`
}

type BoardOpCreateReply

type BoardOpCreateReply struct {
	ArticleID *types.PttID `json:"AID"`
	CommentID *types.PttID `json:"ACD"`

	BlockInfoID *types.PttID   `json:"BID"`
	Hashs       [][][]byte     `json:"H"`
	MediaIDs    []*types.PttID `json:"ms,omitempty"`
}

type BoardOpCreateTitle

type BoardOpCreateTitle struct {
	TitleHash []byte `json:"TH"`
}

type BoardOpDeleteArticle

type BoardOpDeleteArticle struct {
}

type BoardOpDeleteBoard

type BoardOpDeleteBoard struct {
}

type BoardOpDeleteComment

type BoardOpDeleteComment struct {
	ArticleID *types.PttID `json:"AID"`
}

type BoardOpDeleteReply

type BoardOpDeleteReply struct {
	ArticleID *types.PttID `json:"AID"`
	CommentID *types.PttID `json:"ACD"`
}

type BoardOpMigrateBoard

type BoardOpMigrateBoard struct {
	ToID *types.PttID `json:"t"`
}

type BoardOpUpdateArticle

type BoardOpUpdateArticle struct {
	BlockInfoID *types.PttID `json:"BID"`
	Hashs       [][][]byte   `json:"H"`
	NBlock      int          `json:"NB"`

	MediaIDs []*types.PttID `json:"ms,omitempty"`

	TitleHash []byte `json:"th"`
}

type BoardOpUpdateReply

type BoardOpUpdateReply struct {
	BlockInfoID *types.PttID   `json:"BID"`
	Hashs       [][][]byte     `json:"H"`
	MediaIDs    []*types.PttID `json:"ms,omitempty"`
}

type BoardOpUpdateTitle

type BoardOpUpdateTitle struct {
	TitleHash []byte `json:"TH"`
}

type BoardOplog

type BoardOplog struct {
	*pkgservice.BaseOplog `json:"O"`
}

func NewBoardOplog

func NewBoardOplog(objID *types.PttID, ts types.Timestamp, doerID *types.PttID, op pkgservice.OpType, opData pkgservice.OpData, userID *types.PttID, dbLock *types.LockMap) (*BoardOplog, error)

func OplogToBoardOplog

func OplogToBoardOplog(oplog *pkgservice.BaseOplog) *BoardOplog

func OplogsToBoardOplogs

func OplogsToBoardOplogs(logs []*pkgservice.BaseOplog) []*BoardOplog

func (*BoardOplog) GetBaseOplog

func (o *BoardOplog) GetBaseOplog() *pkgservice.BaseOplog

type Comment

type Comment struct {
	*pkgservice.BaseObject `json:"b"`

	UpdateTS types.Timestamp `json:"UT"`

	SyncInfo *pkgservice.BaseSyncInfo `json:"s,omitempty"`

	ArticleID        *types.PttID `json:"AID"`
	ArticleCreatorID *types.PttID `json:"aID"`

	CommentType CommentType `json:"t"`
}

func AliveComments

func AliveComments(typedObjs []*Comment) []*Comment

func NewComment

func NewComment(
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,

	articleID *types.PttID,
	articleCreatorID *types.PttID,
	commentType CommentType,

) (*Comment, error)

func NewEmptyComment

func NewEmptyComment() *Comment

func ObjsToComments

func ObjsToComments(objs []pkgservice.Object) []*Comment

func (*Comment) DeleteAll

func (c *Comment) DeleteAll(isLocked bool) error

func (*Comment) Get

func (c *Comment) Get(isLocked bool) error

func (*Comment) GetAndDeleteAll

func (c *Comment) GetAndDeleteAll(isLocked bool) error

func (*Comment) GetByID

func (c *Comment) GetByID(isLocked bool) error

func (*Comment) GetNewObjByID

func (c *Comment) GetNewObjByID(id *types.PttID, isLocked bool) (pkgservice.Object, error)

func (*Comment) GetSyncInfo

func (c *Comment) GetSyncInfo() pkgservice.SyncInfo

func (*Comment) GetUpdateTS

func (c *Comment) GetUpdateTS() types.Timestamp

func (*Comment) Marshal

func (c *Comment) Marshal() ([]byte, error)

func (*Comment) MarshalKey

func (c *Comment) MarshalKey() ([]byte, error)

func (*Comment) NewEmptyObj

func (c *Comment) NewEmptyObj() pkgservice.Object

func (*Comment) Save

func (c *Comment) Save(isLocked bool) error

func (*Comment) SetSyncInfo

func (c *Comment) SetSyncInfo(theSyncInfo pkgservice.SyncInfo) error

func (*Comment) SetUpdateTS

func (c *Comment) SetUpdateTS(ts types.Timestamp)

func (*Comment) Unmarshal

func (c *Comment) Unmarshal(theBytes []byte) error

type CommentInfo

type CommentInfo struct {
	Op pkgservice.OpType

	ArticleID      *types.PttID
	ContentBlockID *types.PttID
	MediaID        *types.PttID

	Log *BoardOplog
}

type CommentType

type CommentType int

comment type

const (
	CommentTypePush CommentType = iota
	CommentTypeBoo
	CommentTypeNone
)

func (*CommentType) Marshal

func (c *CommentType) Marshal() []byte

type Config

type Config struct {
	DataDir     string
	KeystoreDir string
}

func NewConfig

func NewConfig() (*Config, error)

type ContentBlockInfo

type ContentBlockInfo struct {
	ArticleID *types.PttID `json:"AID"`
	RefID     *types.PttID `json:"RID"`
	ID        *types.PttID
	NBlock    int `json:"N"`
}

type ContentType

type ContentType uint8

content type

const (
	ContentTypeArticle ContentType = iota
	ContentTypeComment
	ContentTypeReply
)

type CreateArticle

type CreateArticle struct {
	Title    []byte
	Article  [][]byte
	MediaIDs []*types.PttID
}

type CreateBoard

type CreateBoard struct {
	Title      []byte                `json:"T"`
	EntityType pkgservice.EntityType `json:"E"`
}

type CreateComment

type CreateComment struct {
	ArticleID   *types.PttID
	CommentType CommentType
	Comment     [][]byte
	MediaIDs    []*types.PttID
}

type CreateTitle

type CreateTitle struct {
	Title []byte
}

type ForceSyncArticleCommentList

type ForceSyncArticleCommentList struct {
	IDs []*types.PttID
}

type LocaleInfo

type LocaleInfo struct {
	DefaultName  string
	DefaultTitle func(myID *types.PttID, creatorID *types.PttID, myName string) []byte
}

type MediaInfo

type MediaInfo struct {
	Op pkgservice.OpType

	ContentBlockID     *types.PttID
	NBlock             int
	OrigContentBlockID *types.PttID
	OrigNBlock         int

	Log *BoardOplog
}

type MetaInfo

type MetaInfo struct {
	Op pkgservice.OpType

	Log *BoardOplog
}

type PrivateAPI

type PrivateAPI struct {
	// contains filtered or unexported fields
}

func NewPrivateAPI

func NewPrivateAPI(b *Backend) *PrivateAPI

func (*PrivateAPI) CountPeers

func (api *PrivateAPI) CountPeers(entityID string) (int, error)

func (*PrivateAPI) CreateArticle

func (api *PrivateAPI) CreateArticle(entityID string, title []byte, article [][]byte, mediaIDs []string) (*BackendCreateArticle, error)

func (*PrivateAPI) CreateBoard

func (api *PrivateAPI) CreateBoard(title []byte, isPrivate bool) (*BackendCreateBoard, error)

func (*PrivateAPI) CreateComment

func (api *PrivateAPI) CreateComment(entityID string, articleID string, commentType CommentType, comment []byte, mediaID string) (*BackendCreateComment, error)

func (*PrivateAPI) CreateReply

func (api *PrivateAPI) CreateReply(entityID string, articleID string, commentID string, reply [][]byte, mediaID string) (*BackendCreateReply, error)

func (*PrivateAPI) DeleteArticle

func (api *PrivateAPI) DeleteArticle(entityID string, articleID string) (*BackendDeleteArticle, error)

func (*PrivateAPI) DeleteBoard

func (api *PrivateAPI) DeleteBoard(entityID string) (bool, error)

func (*PrivateAPI) DeleteComment

func (api *PrivateAPI) DeleteComment(entityID string, articleID string, commentID string) (*BackendDeleteComment, error)

func (*PrivateAPI) DeleteMember

func (api *PrivateAPI) DeleteMember(entityID string, userID string) (bool, error)

func (*PrivateAPI) DeleteReply

func (api *PrivateAPI) DeleteReply(entityID string, articleID string, commentID string) (*BackendDeleteReply, error)

func (*PrivateAPI) ForceSync

func (api *PrivateAPI) ForceSync(entityID string) (bool, error)

func (*PrivateAPI) ForceSyncBoardMerkle

func (api *PrivateAPI) ForceSyncBoardMerkle(entityID string) (bool, error)

func (*PrivateAPI) ForceSyncMasterMerkle

func (api *PrivateAPI) ForceSyncMasterMerkle(entityID string) (bool, error)

func (*PrivateAPI) ForceSyncMemberMerkle

func (api *PrivateAPI) ForceSyncMemberMerkle(entityID string) (bool, error)

func (*PrivateAPI) GetBoardOplogList

func (api *PrivateAPI) GetBoardOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*BoardOplog, error)

func (*PrivateAPI) GetBoardOplogMerkle

func (api *PrivateAPI) GetBoardOplogMerkle(entityID string) (*pkgservice.BackendMerkle, error)

func (*PrivateAPI) GetBoardOplogMerkleNodeList

func (api *PrivateAPI) GetBoardOplogMerkleNodeList(entityID string, level uint8, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.BackendMerkleNode, error)

func (*PrivateAPI) GetFile

func (api *PrivateAPI) GetFile(entityID string, mediaID string) (*BackendGetFile, error)

func (*PrivateAPI) GetImage

func (api *PrivateAPI) GetImage(entityID string, imgID string) (*BackendGetImg, error)

func (*PrivateAPI) GetJoinKeyInfos

func (api *PrivateAPI) GetJoinKeyInfos(entityID string) ([]*pkgservice.KeyInfo, error)

func (*PrivateAPI) GetMasterList

func (api *PrivateAPI) GetMasterList(entityID string, startID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.Master, error)

func (*PrivateAPI) GetMasterListFromCache

func (api *PrivateAPI) GetMasterListFromCache(entityID string) ([]*pkgservice.Master, error)

func (*PrivateAPI) GetMasterOplogList

func (api *PrivateAPI) GetMasterOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MasterOplog, error)

func (*PrivateAPI) GetMasterOplogMerkleNodeList

func (api *PrivateAPI) GetMasterOplogMerkleNodeList(entityID string, level uint8, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.BackendMerkleNode, error)

func (*PrivateAPI) GetMemberList

func (api *PrivateAPI) GetMemberList(entityID string, startID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.Member, error)

func (*PrivateAPI) GetMemberOplogList

func (api *PrivateAPI) GetMemberOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MemberOplog, error)

func (*PrivateAPI) GetMemberOplogMerkleNodeList

func (api *PrivateAPI) GetMemberOplogMerkleNodeList(entityID string, level uint8, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.BackendMerkleNode, error)

func (*PrivateAPI) GetMyMemberLog

func (api *PrivateAPI) GetMyMemberLog(entityID string) (*pkgservice.BaseOplog, error)

func (*PrivateAPI) GetOpKeyInfos

func (api *PrivateAPI) GetOpKeyInfos(entityID string) ([]*pkgservice.KeyInfo, error)

func (*PrivateAPI) GetOpKeyInfosFromDB

func (api *PrivateAPI) GetOpKeyInfosFromDB(entityID string) ([]*pkgservice.KeyInfo, error)

func (*PrivateAPI) GetOpKeyOplogList

func (api *PrivateAPI) GetOpKeyOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.OpKeyOplog, error)

func (*PrivateAPI) GetPeers

func (api *PrivateAPI) GetPeers(entityID string) ([]*pkgservice.BackendPeer, error)

func (*PrivateAPI) GetPendingBoardOplogInternalList

func (api *PrivateAPI) GetPendingBoardOplogInternalList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*BoardOplog, error)

func (*PrivateAPI) GetPendingBoardOplogMasterList

func (api *PrivateAPI) GetPendingBoardOplogMasterList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*BoardOplog, error)

func (*PrivateAPI) GetPendingMasterOplogInternalList

func (api *PrivateAPI) GetPendingMasterOplogInternalList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MasterOplog, error)

func (*PrivateAPI) GetPendingMasterOplogMasterList

func (api *PrivateAPI) GetPendingMasterOplogMasterList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MasterOplog, error)

func (*PrivateAPI) GetPendingMemberOplogInternalList

func (api *PrivateAPI) GetPendingMemberOplogInternalList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MemberOplog, error)

func (*PrivateAPI) GetPendingMemberOplogMasterList

func (api *PrivateAPI) GetPendingMemberOplogMasterList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MemberOplog, error)

func (*PrivateAPI) GetPendingOpKeyOplogInternalList

func (api *PrivateAPI) GetPendingOpKeyOplogInternalList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.OpKeyOplog, error)

func (*PrivateAPI) GetPendingOpKeyOplogMasterList

func (api *PrivateAPI) GetPendingOpKeyOplogMasterList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.OpKeyOplog, error)

func (*PrivateAPI) GetRawArticle

func (api *PrivateAPI) GetRawArticle(entityID string, articleID string) (*Article, error)

func (*PrivateAPI) GetRawBoard

func (api *PrivateAPI) GetRawBoard(entityID string) (*Board, error)

func (*PrivateAPI) GetRawComment

func (api *PrivateAPI) GetRawComment(entityID string, commentID string) (*Comment, error)

func (*PrivateAPI) GetRawReply

func (api *PrivateAPI) GetRawReply(entityID string, articleID string, commentID string) (*Reply, error)

func (*PrivateAPI) GetRawTitle

func (api *PrivateAPI) GetRawTitle(entityID string) (*Title, error)

func (*PrivateAPI) InviteMaster

func (api *PrivateAPI) InviteMaster(entityID string, userID string, nodeURL string) (*BackendInviteMaster, error)

func (*PrivateAPI) LeaveBoard

func (api *PrivateAPI) LeaveBoard(entityID string) (bool, error)

func (*PrivateAPI) MarkArticleSeen

func (api *PrivateAPI) MarkArticleSeen(entityID string, articleID string) (types.Timestamp, error)

func (*PrivateAPI) MarkBoardSeen

func (api *PrivateAPI) MarkBoardSeen(entityID string) (types.Timestamp, error)

func (*PrivateAPI) RevokeOpKey

func (api *PrivateAPI) RevokeOpKey(entityID string, keyID string, myKey string) (bool, error)

func (*PrivateAPI) SetTitle

func (api *PrivateAPI) SetTitle(entityID string, title []byte) (*BackendGetBoard, error)

func (*PrivateAPI) ShowValidateKey

func (api *PrivateAPI) ShowValidateKey() (*types.PttID, error)

func (*PrivateAPI) UpdateArticle

func (api *PrivateAPI) UpdateArticle(entityID string, articleID string, article [][]byte, mediaIDs []string) (*BackendUpdateArticle, error)

func (*PrivateAPI) UpdateReply

func (api *PrivateAPI) UpdateReply(entityID string, articleID string, commentID string, reply [][]byte, mediaID string) (*BackendUpdateReply, error)

func (*PrivateAPI) UploadFile

func (api *PrivateAPI) UploadFile(entityID string, filename string, bytes []byte) (*BackendUploadFile, error)

func (*PrivateAPI) UploadImage

func (api *PrivateAPI) UploadImage(entityID string, fileType string, bytes []byte) (*BackendUploadImg, error)

func (*PrivateAPI) ValidateValidateKey

func (api *PrivateAPI) ValidateValidateKey(key string) (bool, error)

type ProcessBoardInfo

type ProcessBoardInfo struct {
	CreateTitleInfo map[types.PttID]*pkgservice.BaseOplog
	TitleInfo       map[types.PttID]*pkgservice.BaseOplog

	CreateArticleInfo map[types.PttID]*pkgservice.BaseOplog
	ArticleInfo       map[types.PttID]*pkgservice.BaseOplog
	ArticleBlockInfo  map[types.PttID]*pkgservice.BaseOplog

	CreateCommentInfo map[types.PttID]*pkgservice.BaseOplog
	CommentInfo       map[types.PttID]*pkgservice.BaseOplog
	CommentBlockInfo  map[types.PttID]*pkgservice.BaseOplog

	CreateReplyInfo map[types.PttID]*pkgservice.BaseOplog
	ReplyInfo       map[types.PttID]*pkgservice.BaseOplog
	ReplyBlockInfo  map[types.PttID]*pkgservice.BaseOplog

	CreateMediaInfo map[types.PttID]*pkgservice.BaseOplog
	MediaInfo       map[types.PttID]*pkgservice.BaseOplog
	MediaBlockInfo  map[types.PttID]*pkgservice.BaseOplog

	BoardInfo map[types.PttID]*pkgservice.BaseOplog
}

func NewProcessBoardInfo

func NewProcessBoardInfo() *ProcessBoardInfo

type ProtocolManager

type ProtocolManager struct {
	*pkgservice.BaseProtocolManager
	// contains filtered or unexported fields
}

func NewProtocolManager

func NewProtocolManager(b *Board, ptt pkgservice.Ptt, svc pkgservice.Service) (*ProtocolManager, error)

func (*ProtocolManager) BroadcastBoardOplog

func (pm *ProtocolManager) BroadcastBoardOplog(oplog *BoardOplog) error

func (*ProtocolManager) BroadcastBoardOplogs

func (pm *ProtocolManager) BroadcastBoardOplogs(opKeyLogs []*BoardOplog) error

func (*ProtocolManager) CleanObject

func (pm *ProtocolManager) CleanObject() error

func (*ProtocolManager) CreateArticle

func (pm *ProtocolManager) CreateArticle(title []byte, articleBytes [][]byte, mediaIDs []*types.PttID) (*Article, error)

func (*ProtocolManager) CreateBoardOplog

func (pm *ProtocolManager) CreateBoardOplog(objID *types.PttID, ts types.Timestamp, op pkgservice.OpType, data interface{}) (*BoardOplog, error)

func (*ProtocolManager) CreateComment

func (pm *ProtocolManager) CreateComment(articleID *types.PttID, commentType CommentType, commentBytes []byte, mediaID *types.PttID) (*Comment, error)

func (*ProtocolManager) CreateTitle

func (pm *ProtocolManager) CreateTitle(title []byte) error

func (*ProtocolManager) DeleteArticle

func (pm *ProtocolManager) DeleteArticle(id *types.PttID) error

func (*ProtocolManager) DeleteBoard

func (pm *ProtocolManager) DeleteBoard() error

func (*ProtocolManager) DeleteComment

func (pm *ProtocolManager) DeleteComment(id *types.PttID) error

func (*ProtocolManager) Fix237PrelogInCreateArticle

func (pm *ProtocolManager) Fix237PrelogInCreateArticle() error

func (*ProtocolManager) ForceSyncArticle

func (pm *ProtocolManager) ForceSyncArticle(syncIDs []*pkgservice.ForceSyncID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) ForceSyncArticleCommentList

func (pm *ProtocolManager) ForceSyncArticleCommentList(
	ids []*types.PttID,
	peer *pkgservice.PttPeer,
) error

func (*ProtocolManager) ForceSyncBoardMerkle

func (pm *ProtocolManager) ForceSyncBoardMerkle() (bool, error)

func (*ProtocolManager) ForceSyncComment

func (pm *ProtocolManager) ForceSyncComment(syncIDs []*pkgservice.ForceSyncID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) ForceSyncTitle

func (pm *ProtocolManager) ForceSyncTitle(syncIDs []*pkgservice.ForceSyncID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) GetArticle

func (pm *ProtocolManager) GetArticle(articleID *types.PttID) (*Article, error)

func (*ProtocolManager) GetArticleBlockList

func (pm *ProtocolManager) GetArticleBlockList(articleID *types.PttID, subContentID *types.PttID, contentType ContentType, blockID uint32, limit int, listOrder pttdb.ListOrder) ([]*ArticleBlock, error)

func (*ProtocolManager) GetArticleList

func (pm *ProtocolManager) GetArticleList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Article, error)

func (*ProtocolManager) GetBoardOplogList

func (pm *ProtocolManager) GetBoardOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*BoardOplog, error)

GetBoardOplogList gets the BoardOplogs.

func (*ProtocolManager) GetBoardOplogMerkleNodeList

func (pm *ProtocolManager) GetBoardOplogMerkleNodeList(level pkgservice.MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MerkleNode, error)

func (*ProtocolManager) GetComment

func (pm *ProtocolManager) GetComment(commentID *types.PttID) (*Comment, error)

func (*ProtocolManager) GetJoinType

func (pm *ProtocolManager) GetJoinType(hash *common.Address) (pkgservice.JoinType, error)

func (*ProtocolManager) GetTitle

func (pm *ProtocolManager) GetTitle() (*Title, error)

func (*ProtocolManager) HandleAddBoardOplog

func (pm *ProtocolManager) HandleAddBoardOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleAddBoardOplogs

func (pm *ProtocolManager) HandleAddBoardOplogs(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleAddPendingBoardOplog

func (pm *ProtocolManager) HandleAddPendingBoardOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleAddPendingBoardOplogs

func (pm *ProtocolManager) HandleAddPendingBoardOplogs(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleBoardOplogs

func (pm *ProtocolManager) HandleBoardOplogs(oplogs []*pkgservice.BaseOplog, peer *pkgservice.PttPeer, isUpdateSyncTime bool) error

func (*ProtocolManager) HandleFailedBoardOplog

func (pm *ProtocolManager) HandleFailedBoardOplog(oplog *pkgservice.BaseOplog) (err error)

func (*ProtocolManager) HandleFailedValidBoardOplog

func (pm *ProtocolManager) HandleFailedValidBoardOplog(oplog *pkgservice.BaseOplog, processInfo pkgservice.ProcessInfo) (err error)

func (*ProtocolManager) HandleForceSyncAricleCommentList

func (pm *ProtocolManager) HandleForceSyncAricleCommentList(
	dataBytes []byte,
	peer *pkgservice.PttPeer,

) error

func (*ProtocolManager) HandleForceSyncArticle

func (pm *ProtocolManager) HandleForceSyncArticle(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncArticleAck

func (pm *ProtocolManager) HandleForceSyncArticleAck(
	dataBytes []byte,
	peer *pkgservice.PttPeer,
) error

func (*ProtocolManager) HandleForceSyncBoardOplog

func (pm *ProtocolManager) HandleForceSyncBoardOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncBoardOplogAck

func (pm *ProtocolManager) HandleForceSyncBoardOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncBoardOplogByMerkle

func (pm *ProtocolManager) HandleForceSyncBoardOplogByMerkle(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncBoardOplogByMerkleAck

func (pm *ProtocolManager) HandleForceSyncBoardOplogByMerkleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncBoardOplogByOplogAck

func (pm *ProtocolManager) HandleForceSyncBoardOplogByOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncComment

func (pm *ProtocolManager) HandleForceSyncComment(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncCommentAck

func (pm *ProtocolManager) HandleForceSyncCommentAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncTitle

func (pm *ProtocolManager) HandleForceSyncTitle(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncTitleAck

func (pm *ProtocolManager) HandleForceSyncTitleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleMessage

func (pm *ProtocolManager) HandleMessage(op pkgservice.OpType, dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandlePendingBoardOplogs

func (pm *ProtocolManager) HandlePendingBoardOplogs(oplogs []*pkgservice.BaseOplog, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncArticleBlock

func (pm *ProtocolManager) HandleSyncArticleBlock(dataBytes []byte, peer *pkgservice.PttPeer, ackMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncBoardOplog

func (pm *ProtocolManager) HandleSyncBoardOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncBoardOplogAck

func (pm *ProtocolManager) HandleSyncBoardOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncBoardOplogInvalid

func (pm *ProtocolManager) HandleSyncBoardOplogInvalid(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncCommentBlock

func (pm *ProtocolManager) HandleSyncCommentBlock(dataBytes []byte, peer *pkgservice.PttPeer, ackMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncCreateArticle

func (pm *ProtocolManager) HandleSyncCreateArticle(dataBytes []byte, peer *pkgservice.PttPeer, syncAckMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncCreateArticleAck

func (pm *ProtocolManager) HandleSyncCreateArticleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncCreateArticleBlockAck

func (pm *ProtocolManager) HandleSyncCreateArticleBlockAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncCreateComment

func (pm *ProtocolManager) HandleSyncCreateComment(dataBytes []byte, peer *pkgservice.PttPeer, syncAckMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncCreateCommentAck

func (pm *ProtocolManager) HandleSyncCreateCommentAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncCreateCommentBlockAck

func (pm *ProtocolManager) HandleSyncCreateCommentBlockAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncCreateTitle

func (pm *ProtocolManager) HandleSyncCreateTitle(dataBytes []byte, peer *pkgservice.PttPeer, syncAckMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncCreateTitleAck

func (pm *ProtocolManager) HandleSyncCreateTitleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncNewBoardOplog

func (pm *ProtocolManager) HandleSyncNewBoardOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncNewBoardOplogAck

func (pm *ProtocolManager) HandleSyncNewBoardOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncPendingBoardOplog

func (pm *ProtocolManager) HandleSyncPendingBoardOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncPendingBoardOplogAck

func (pm *ProtocolManager) HandleSyncPendingBoardOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncUpdateArticle

func (pm *ProtocolManager) HandleSyncUpdateArticle(dataBytes []byte, peer *pkgservice.PttPeer, syncAckMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncUpdateArticleAck

func (pm *ProtocolManager) HandleSyncUpdateArticleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncUpdateArticleBlockAck

func (pm *ProtocolManager) HandleSyncUpdateArticleBlockAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncUpdateTitle

func (pm *ProtocolManager) HandleSyncUpdateTitle(dataBytes []byte, peer *pkgservice.PttPeer, syncAckMsg pkgservice.OpType) error

func (*ProtocolManager) HandleSyncUpdateTitleAck

func (pm *ProtocolManager) HandleSyncUpdateTitleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) MigrateBoard

func (pm *ProtocolManager) MigrateBoard(toID *types.PttID) error

func (*ProtocolManager) NewArticle

func (*ProtocolManager) NewBoardOplog

func (pm *ProtocolManager) NewBoardOplog(objID *types.PttID, op pkgservice.OpType, opData pkgservice.OpData) (pkgservice.Oplog, error)

func (*ProtocolManager) NewBoardOplogWithTS

func (pm *ProtocolManager) NewBoardOplogWithTS(objID *types.PttID, ts types.Timestamp, op pkgservice.OpType, opData pkgservice.OpData) (pkgservice.Oplog, error)

func (*ProtocolManager) NewComment

func (*ProtocolManager) NewTitle

func (*ProtocolManager) SaveArticleLastSeen

func (pm *ProtocolManager) SaveArticleLastSeen(articleID *types.PttID, ts types.Timestamp) (types.Timestamp, error)

func (*ProtocolManager) SaveLastSeen

func (pm *ProtocolManager) SaveLastSeen(ts types.Timestamp) (types.Timestamp, error)

func (*ProtocolManager) SetArticleDB

func (pm *ProtocolManager) SetArticleDB(u *Article)

func (*ProtocolManager) SetBoardDB

func (pm *ProtocolManager) SetBoardDB(oplog *pkgservice.BaseOplog)

func (*ProtocolManager) SetBoardOplogIsSync

func (pm *ProtocolManager) SetBoardOplogIsSync(oplog *BoardOplog, isBroadcast bool) (bool, error)

func (*ProtocolManager) SetCommentDB

func (pm *ProtocolManager) SetCommentDB(u *Comment)

func (*ProtocolManager) SetNewestBoardOplog

func (pm *ProtocolManager) SetNewestBoardOplog(oplog *pkgservice.BaseOplog) (err error)

func (*ProtocolManager) SetTitle

func (pm *ProtocolManager) SetTitle(title []byte) error

func (*ProtocolManager) SetTitleDB

func (pm *ProtocolManager) SetTitleDB(u *Title)

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start() error

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop() error

func (*ProtocolManager) Sync

func (pm *ProtocolManager) Sync(peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncArticle

func (pm *ProtocolManager) SyncArticle(op pkgservice.OpType, syncIDs []*pkgservice.SyncID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncArticleBlock

func (pm *ProtocolManager) SyncArticleBlock(op pkgservice.OpType, syncBlockIDs []*pkgservice.SyncBlockID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncBoardOplog

func (pm *ProtocolManager) SyncBoardOplog(peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncComment

func (pm *ProtocolManager) SyncComment(op pkgservice.OpType, syncIDs []*pkgservice.SyncID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncCommentBlock

func (pm *ProtocolManager) SyncCommentBlock(op pkgservice.OpType, syncBlockIDs []*pkgservice.SyncBlockID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncPendingBoardOplog

func (pm *ProtocolManager) SyncPendingBoardOplog(peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncTitle

func (pm *ProtocolManager) SyncTitle(op pkgservice.OpType, syncIDs []*pkgservice.SyncID, peer *pkgservice.PttPeer) error

func (*ProtocolManager) UpdateArticle

func (pm *ProtocolManager) UpdateArticle(articleID *types.PttID, articleBytes [][]byte, mediaIDs []*types.PttID) (*Article, error)

func (*ProtocolManager) UpdateTitle

func (pm *ProtocolManager) UpdateTitle(title []byte) error

func (*ProtocolManager) UploadFile

func (pm *ProtocolManager) UploadFile(filename []byte, theBytes []byte) (*pkgservice.Media, error)

func (*ProtocolManager) UploadImage

func (pm *ProtocolManager) UploadImage(fileType string, theBytes []byte) (*pkgservice.Media, error)

type PublicAPI

type PublicAPI struct {
	// contains filtered or unexported fields
}

func NewPublicAPI

func NewPublicAPI(b *Backend) *PublicAPI

func (*PublicAPI) GetArticle

func (api *PublicAPI) GetArticle(entityID string, articleID string) (*BackendGetArticle, error)

func (*PublicAPI) GetArticleBlockList

func (api *PublicAPI) GetArticleBlockList(entityID string, articleID string, subContentID string, contentType ContentType, blockID uint32, limit int, listOrder pttdb.ListOrder) ([]*ArticleBlock, error)

GetArticleBlockList gets the list of the blocks-to-show of the article, including main-article, comment, reply.

Given the entityID, articleID, and the corresponding subContentID (article: ContentBlockID, comment: commentID, reply: replyID), and the blockID (for comment and reply: blockID as 0) GetArticleBlockList will get the following blocks from the specified subContentID and blockID.

func (*PublicAPI) GetArticleList

func (api *PublicAPI) GetArticleList(entityID string, startingArticleID string, limit int, listOrder pttdb.ListOrder) ([]*BackendGetArticle, error)

func (*PublicAPI) GetArticleSummary

func (api *PublicAPI) GetArticleSummary(entityID string, articleInfo *BackendArticleSummaryParams) (*ArticleBlock, error)

func (*PublicAPI) GetArticleSummaryByIDs

func (api *PublicAPI) GetArticleSummaryByIDs(entityID string, articleInfos []*BackendArticleSummaryParams) (map[string]*ArticleBlock, error)

func (*PublicAPI) GetBoard

func (api *PublicAPI) GetBoard(entityID string) (*BackendGetBoard, error)

func (*PublicAPI) GetBoardList

func (api *PublicAPI) GetBoardList(startingBoardID string, limit int, listOrder pttdb.ListOrder) ([]*BackendGetBoard, error)

func (*PublicAPI) GetPokedArticleList

func (api *PublicAPI) GetPokedArticleList(entityID string) ([]*BackendGetArticle, error)

func (*PublicAPI) ShowBoardURL

func (api *PublicAPI) ShowBoardURL(entityID string) (*pkgservice.BackendJoinURL, error)

type Reply

type Reply struct {
}

func NewReply

func NewReply() (*Reply, error)

type ReplyInfo

type ReplyInfo struct {
	Op pkgservice.OpType

	ArticleID      *types.PttID `json:"AID"`
	CommentID      *types.PttID `json:"CID"`
	ContentBlockID *types.PttID `json:"cID"`
	MediaID        *types.PttID

	Log *BoardOplog
}

type ServiceProtocolManager

type ServiceProtocolManager struct {
	*pkgservice.BaseServiceProtocolManager
}

func NewServiceProtocolManager

func NewServiceProtocolManager(ptt pkgservice.Ptt, service pkgservice.Service) (*ServiceProtocolManager, error)

func (*ServiceProtocolManager) CreateBoard

func (spm *ServiceProtocolManager) CreateBoard(title []byte, entityType pkgservice.EntityType) (*Board, error)

func (*ServiceProtocolManager) GetBoardList

func (spm *ServiceProtocolManager) GetBoardList(startingBoardID *types.PttID, limit int, listOrder pttdb.ListOrder) ([]*Board, error)

func (*ServiceProtocolManager) NewBoard

func (*ServiceProtocolManager) NewBoardOplogWithTS

func (spm *ServiceProtocolManager) NewBoardOplogWithTS(entityID *types.PttID, ts types.Timestamp, op pkgservice.OpType, opData pkgservice.OpData) (pkgservice.Oplog, error)

func (*ServiceProtocolManager) NewEmptyEntity

func (spm *ServiceProtocolManager) NewEmptyEntity() pkgservice.Entity

type SyncArticleAck

type SyncArticleAck struct {
	Objs []*Article `json:"o"`
}

type SyncArticleInfo

type SyncArticleInfo struct {
	*pkgservice.BaseSyncInfo `json:"b"`

	Title []byte `json:"T,omitempty"`
}

func NewEmptySyncArticleInfo

func NewEmptySyncArticleInfo() *SyncArticleInfo

func (*SyncArticleInfo) ToObject

func (s *SyncArticleInfo) ToObject(theObj pkgservice.Object) error

type SyncCommentAck

type SyncCommentAck struct {
	Objs []*Comment `json:"o"`
}

type SyncID

type SyncID struct {
	ID    *types.PttID
	LogID *types.PttID `json:"l"`
}

type SyncReplyID

type SyncReplyID struct {
	ArticleID *types.PttID `json:"a"`
	CommentID *types.PttID `json:"c"`
	LogID     *types.PttID `json:"l"`
}

type SyncTitleAck

type SyncTitleAck struct {
	Objs []*Title `json:"o"`
}

type SyncTitleInfo

type SyncTitleInfo struct {
	*pkgservice.BaseSyncInfo `json:"b"`

	Title []byte `json:"T,omitempty"`
}

func NewEmptySyncTitleInfo

func NewEmptySyncTitleInfo() *SyncTitleInfo

func (*SyncTitleInfo) ToObject

func (s *SyncTitleInfo) ToObject(theObj pkgservice.Object) error

type SyncUpdateArticleAck

type SyncUpdateArticleAck struct {
	Objs []*Article `json:"o"`
}

type SyncUpdateTitleAck

type SyncUpdateTitleAck struct {
	Objs []*Title `json:"o"`
}

type Title

type Title struct {
	*pkgservice.BaseObject `json:"b"`
	UpdateTS               types.Timestamp `json:"UT"`

	SyncInfo *SyncTitleInfo `json:"s,omitempty"`

	Title []byte `json:"T,omitempty"`
}

func AliveTitles

func AliveTitles(typedObjs []*Title) []*Title

func NewEmptyTitle

func NewEmptyTitle() *Title

func NewTitle

func NewTitle(
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,

	title []byte,

) (*Title, error)

func ObjsToTitles

func ObjsToTitles(objs []pkgservice.Object) []*Title

func (*Title) Get

func (t *Title) Get(isLocked bool) error

func (*Title) GetByID

func (t *Title) GetByID(isLocked bool) error

func (*Title) GetNewObjByID

func (t *Title) GetNewObjByID(id *types.PttID, isLocked bool) (pkgservice.Object, error)

func (*Title) GetSyncInfo

func (t *Title) GetSyncInfo() pkgservice.SyncInfo

func (*Title) GetUpdateTS

func (t *Title) GetUpdateTS() types.Timestamp

func (*Title) Marshal

func (t *Title) Marshal() ([]byte, error)

func (*Title) MarshalKey

func (t *Title) MarshalKey() ([]byte, error)

func (*Title) NewEmptyObj

func (t *Title) NewEmptyObj() pkgservice.Object

func (*Title) Save

func (t *Title) Save(isLocked bool) error

func (*Title) SetSyncInfo

func (t *Title) SetSyncInfo(theSyncInfo pkgservice.SyncInfo) error

func (*Title) SetUpdateTS

func (t *Title) SetUpdateTS(ts types.Timestamp)

func (*Title) Unmarshal

func (t *Title) Unmarshal(theBytes []byte) error

type UpdateArticle

type UpdateArticle struct {
	Article  [][]byte       `json:"a"`
	MediaIDs []*types.PttID `json:"m"`
}

type UpdateTitle

type UpdateTitle struct {
	Title []byte `json:"t"`
}

type UploadFile

type UploadFile struct {
	Filename []byte
	Bytes    []byte
}

type UploadImage

type UploadImage struct {
	FileType string
	Bytes    []byte
}

Source Files

Jump to

Keyboard shortcuts

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