repository

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BBSUserRecord

type BBSUserRecord interface {
	bbs.UserRecord
	NumBadPosts() int
	LastCountry() string
	MailboxDescription() string
	ChessStatus() map[string]interface{}
	Plan() map[string]interface{}
}

BBSUserRecord : currently interface `bbs.UserRecord` of go-bbs lacks some required methods, so we use a mock

type ForwardArticleToBoardRecord added in v0.0.2

type ForwardArticleToBoardRecord interface {
	// Note: go-bbs has not implemented this yet
	// TODO: use bbs.ForwardArticleToBoardRecord or something when it is ready
	bbs.ArticleRecord
	DestBoardID() string
	IPAddr() string
	ForwardTime() time.Time
	ForwardTitle() string
}

type PopularArticleRecord

type PopularArticleRecord interface {
	// Note: go-bbs has not implemented this yet
	// TODO: use bbs.PopularArticleRecord or something when it is ready
	bbs.ArticleRecord
	BoardID() string
}

PopularArticleRecord is an ArticleRecord which has boardID information.

type Push added in v0.10.0

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

func (*Push) ID added in v0.10.0

func (p *Push) ID() string

func (*Push) IPAddr added in v0.10.0

func (p *Push) IPAddr() string

func (*Push) Text added in v0.10.0

func (p *Push) Text() string

func (*Push) Time added in v0.10.0

func (p *Push) Time() time.Time

func (*Push) Type added in v0.10.0

func (p *Push) Type() string

type PushRecord added in v0.0.2

type PushRecord interface {
	// TODO: use bbs.PushRecord instead
	Type() string
	ID() string
	IPAddr() string
	Text() string
	Time() time.Time
}

type Repository

type Repository interface {

	// board.go
	// GetBoards return all board record
	GetBoards(ctx context.Context) []bbs.BoardRecord
	// GetBoardArticle returns an article file in a specified board and filename
	GetBoardArticle(ctx context.Context, boardID, filename string) ([]byte, error)
	// GetBoardArticleRecords returns article records of a board
	GetBoardArticleRecords(ctx context.Context, boardID string) ([]bbs.ArticleRecord, error)
	// GetBoardTreasureRecords returns treasure article records of a board
	GetBoardTreasureRecords(ctx context.Context, boardID string, treasureIDs []string) ([]bbs.ArticleRecord, error)

	// user.go
	// GetUsers returns all user records
	GetUsers(ctx context.Context) ([]bbs.UserRecord, error)
	// GetUserFavoriteRecords returns favorite records of a user
	GetUserFavoriteRecords(ctx context.Context, userID string) ([]bbs.FavoriteRecord, error)
	// GetUserArticles returns user's articles
	GetUserArticles(ctx context.Context, boardID string) ([]bbs.ArticleRecord, error)
	// GetUserPreferences returns user's preferences
	// TODO: replace UserPreferencesRecord with real bbs record
	GetUserPreferences(ctx context.Context, userID string) (map[string]string, error)
	// GetUserComments return user's history comments
	// TODO: return a slice of concrete type not interface
	GetUserComments(ctx context.Context, userID string) ([]bbs.UserCommentRecord, error)
	// GetUserDrafts returns user's draft according to draftID
	GetUserDrafts(ctx context.Context, userID, draftID string) (bbs.UserDraft, error)
	// UpdateUserDraft updates user's draft according to draftID
	UpdateUserDraft(ctx context.Context, userID, draftID string, text []byte) (bbs.UserDraft, error)
	// DeleteUserDraft deletes user's draft according to draftID
	DeleteUserDraft(ctx context.Context, userID, draftID string) error

	// article.go
	// GetPopularArticles returns all popular articles
	GetPopularArticles(ctx context.Context) ([]PopularArticleRecord, error)
	// AppendComment returns comment details
	AppendComment(ctx context.Context, userID, boardID, filename, appendType, text string) (PushRecord, error)
	// CreateArticle
	// TODO: return result from bbs response
	CreateArticle(ctx context.Context, userID, boardID, title, article string) (bbs.ArticleRecord, error)
	// GetRawArticle
	GetRawArticle(boardID, filename string) (string, error)
	// ForwardArticleToBoard returns forwarding to board results
	ForwardArticleToBoard(ctx context.Context, userID, boardID, filename, boardName string) (ForwardArticleToBoardRecord, error)
}

Repository directly interacts with database via db handler.

func NewRepository

func NewRepository(db *bbs.DB) (Repository, error)

Jump to

Keyboard shortcuts

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