comment

package
v0.0.0-...-1ad4281 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContentLength max 4096
	ErrContentLength = errtools.InvalidLen(2, 4096)
)
View Source
var ErrNoComment = errors.New("post/comment: Error No Comment Found OR Insufficient permission to view this Comment")

Functions

func CanReplyTo

func CanReplyTo(commentID, postID int64, u *session.Session, commentCache ...*Comment) error

func CanView

func CanView(commentID int64, u *session.Session, commentCache ...*Comment) error

func ContentValid

func ContentValid(content string) error

ContentValid Comment content valid

func Delete

func Delete(commentID int64) error

Delete commentID

func GetPostID

func GetPostID(commentID int64) (int64, error)

func GetPostTopLevel

func GetPostTopLevel(postID int64) (total int64, err error)

GetPostTopLevel Get total top level (not a reply) comments for a post

func GetPostTotal

func GetPostTotal(postID int64, depth ...int64) (total int64, err error)

GetTotal comments for post

func GetRepliesTotal

func GetRepliesTotal(commentID int64, depth ...int64) (total int64, err error)

GetRepliesTotal

func GetUserId

func GetUserId(commentID int64) (int64, error)

func UpdateContent

func UpdateContent(commentID int64, content string) error

Types

type Comment

type Comment struct {
	ID     int64 `msg:"id" json:"id"`
	UserID int64 `msg:"userId" json:"userId"`
	PostID int64 `msg:"postId" json:"postId"`
	// ParentID comment id
	ParentID int64              `msg:"parentId" json:"parentId"`
	Created  int64              `msg:"created" json:"created"`
	Updated  int64              `msg:"updated" json:"updated"`
	Content  string             `msg:"content" json:"content"`
	Replies  int64              `msg:"replies" json:"replies"`
	Depth    int64              `msg:"depth" json:"depth"`
	Children map[int64]*Comment `msg:"children" json:"children"`
}

func Get

func Get(commentId int64) (*Comment, error)

Get

func GetForUser

func GetForUser(commentId int64, u *session.Session) (*Comment, error)

GetForUser

func GetPostUserID

func GetPostUserID(commentID int64) (*Comment, error)

func New

func New(userID, postID, ParentID int64, content string) *Comment

func (*Comment) CountReplies

func (c *Comment) CountReplies() (err error)

func (*Comment) DecodeMsg

func (z *Comment) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Comment) EncodeMsg

func (z *Comment) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Comment) Insert

func (c *Comment) Insert() (err error)

func (*Comment) MarshalMsg

func (z *Comment) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Comment) Msgsize

func (z *Comment) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Comment) UnmarshalMsg

func (z *Comment) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*Comment) Validate

func (c *Comment) Validate() error

Validate is content valid

type CommentList

type CommentList map[int64]*Comment

type List

type List struct {
	ListComments
	Order map[int64]int64 `msg:"order" json:"order"`
}

func GetPostComments

func GetPostComments(startNum, topPerPage, maxPerPage, postID int64, depth int64) (*List, error)

GetPostComments

topPerPage maximum num of top level comments per page

func GetReplies

func GetReplies(startNum, perPage, commentID int64, depth int64) (*List, error)

func NewList

func NewList() *List

func (*List) DecodeMsg

func (z *List) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*List) EncodeMsg

func (z *List) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*List) MarshalMsg

func (z *List) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*List) Msgsize

func (z *List) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*List) UnmarshalMsg

func (z *List) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ListComments

type ListComments struct {
	Comments map[int64]*Comment `msg:"comments" json:"comments"`
}

func (*ListComments) DecodeMsg

func (z *ListComments) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ListComments) EncodeMsg

func (z ListComments) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (ListComments) MarshalMsg

func (z ListComments) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ListComments) Msgsize

func (z ListComments) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ListComments) UnmarshalMsg

func (z *ListComments) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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