thread

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "Thread"

Variables

View Source
var (
	ErrNoTitle      = errors.New("missing title")
	ErrNoBody       = errors.New("missing body")
	ErrUnauthorised = errors.New("unauthorised")
)

Functions

func WithID

func WithID(id post.PostID) option

Types

type AuthorRef

type AuthorRef struct {
	ID   account.AccountID
	Name string
}

type Repository

type Repository interface {
	// Create a new thread. A thread is just a "post" in the underlying data
	// model. But a thread is marked as "first" and has a title, catgegory and
	// tags, and no parent post.
	Create(
		ctx context.Context,
		title string,
		body string,
		authorID account.AccountID,
		categoryID category.CategoryID,
		tags []string,
		opts ...option,
	) (*Thread, error)

	List(
		ctx context.Context,
		before time.Time,
		max int,
	) ([]*Thread, error)

	Get(ctx context.Context, threadID post.PostID) (*Thread, error)
}

func New

func New(db *model.Client) Repository

type Thread

type Thread struct {
	ID        post.PostID
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt optional.Optional[time.Time]

	Title    string
	Slug     string
	Short    string
	Pinned   bool
	Author   AuthorRef
	Tags     []string
	Category category.Category
	Posts    []*post.Post
	Reacts   []*react.React
}

func FromModel

func FromModel(m *model.Post) *Thread

func (*Thread) GetResourceName

func (*Thread) GetResourceName() string

func (*Thread) GetRole

func (*Thread) GetRole() string

Jump to

Keyboard shortcuts

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