post

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

Documentation

Index

Constants

View Source
const MaxShortBodyLength = 128

MaxShortBodyLength is the maximum length of the short summary text

View Source
const Role = "Post"

Variables

View Source
var (
	ErrNoTitle        = errors.New("missing title")
	ErrNoBody         = errors.New("missing body")
	ErrUnauthorised   = errors.New("unauthorised")
	ErrTagNameTooLong = errors.New("tag name too long")
)

Functions

func CanUserMutatePost

func CanUserMutatePost(ctx context.Context, d *model.Client, authorID, postID PostID) error

func MakeShortBody

func MakeShortBody(long string) string

MakeShortBody produces a short summary of a long piece of markdown content.

Types

type Author

type Author struct {
	ID        account.AccountID `json:"id"`
	Name      string            `json:"name"`
	Admin     bool              `json:"admin"`
	CreatedAt time.Time         `json:"createdAt"`
}

type Post

type Post struct {
	ID PostID `json:"id"`

	Body       string                    `json:"body"`
	Short      string                    `json:"short"`
	Author     Author                    `json:"author"`
	RootPostID PostID                    `json:"rootPostId"`
	ReplyTo    optional.Optional[PostID] `json:"replyTo"`
	Reacts     []react.React             `json:"reacts"`

	CreatedAt time.Time                    `json:"createdAt"`
	UpdatedAt time.Time                    `json:"updatedAt"`
	DeletedAt optional.Optional[time.Time] `json:"deletedAt"`
}

func FromModel

func FromModel(m *model.Post) (w *Post)

func (*Post) GetRole

func (u *Post) GetRole() string

type PostID

type PostID xid.ID

func (PostID) String

func (u PostID) String() string

type Repository

type Repository interface {
	Create(
		ctx context.Context,
		body string,
		authorID account.AccountID,
		parentID PostID,
		replyToID optional.Optional[PostID],
	) (*Post, error)
}

func New

func New(db *model.Client) Repository

Jump to

Keyboard shortcuts

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