comments

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const CommentMessagePreviewLength = 60
View Source
const MaxMessageLength = 16 * 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentMessage added in v1.41.0

type CommentMessage struct {
	ID                 int64              `db:"id"`
	TypeID             CommentType        `db:"type_id"`
	ItemID             int64              `db:"item_id"`
	ParentID           sql.NullInt64      `db:"parent_id"`
	CreatedAt          time.Time          `db:"datetime"`
	Deleted            bool               `db:"deleted"`
	ModeratorAttention ModeratorAttention `db:"moderator_attention"`
	AuthorID           sql.NullInt64      `db:"author_id"`
	IP                 net.IP             `db:"ip"`
	Message            string             `db:"message"`
	Vote               int32              `db:"vote"`
}

type CommentType

type CommentType int32
const (
	TypeIDPictures CommentType = 1
	TypeIDItems    CommentType = 2
	TypeIDVotings  CommentType = 3
	TypeIDArticles CommentType = 4
	TypeIDForums   CommentType = 5
)

type GetVotesResult

type GetVotesResult struct {
	PositiveVotes []users.DBUser
	NegativeVotes []users.DBUser
}

type ModeratorAttention

type ModeratorAttention int32
const (
	ModeratorAttentionNone      ModeratorAttention = 0
	ModeratorAttentionRequired  ModeratorAttention = 1
	ModeratorAttentionCompleted ModeratorAttention = 2
)

type Repository

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

Repository Main Object.

func NewRepository

func NewRepository(
	db *goqu.Database,
	userRepository *users.Repository,
	messageRepository *messaging.Repository,
	hostManager *hosts.Manager,
	i18n *i18nbundle.I18n,
) *Repository

NewRepository constructor.

func (*Repository) Add added in v1.18.0

func (s *Repository) Add(
	ctx context.Context,
	typeID CommentType,
	itemID int64,
	parentID int64,
	userID int64,
	message string,
	addr string,
	attention bool,
) (int64, error)

func (*Repository) AssertItem added in v1.18.0

func (s *Repository) AssertItem(ctx context.Context, typeID CommentType, itemID int64) error

func (*Repository) CleanBrokenMessages added in v1.26.0

func (s *Repository) CleanBrokenMessages(ctx context.Context) (int64, error)

func (*Repository) CleanTopics added in v1.27.0

func (s *Repository) CleanTopics(ctx context.Context) (int64, error)

func (*Repository) CleanupDeleted added in v1.18.0

func (s *Repository) CleanupDeleted(ctx context.Context) (int64, error)

func (*Repository) CompleteMessage added in v1.18.0

func (s *Repository) CompleteMessage(ctx context.Context, id int64) error

func (*Repository) GetCommentType

func (s *Repository) GetCommentType(ctx context.Context, commentID int64) (CommentType, error)

func (*Repository) GetVotes

func (s *Repository) GetVotes(ctx context.Context, id int64) (*GetVotesResult, error)

func (*Repository) IsNewMessage added in v1.41.0

func (s *Repository) IsNewMessage(
	ctx context.Context, typeID CommentType, itemID int64, msgTime time.Time, userID int64,
) (bool, error)

func (*Repository) IsSubscribed added in v1.37.0

func (s *Repository) IsSubscribed(
	ctx context.Context, userID int64, commentsType CommentType, itemID int64,
) (bool, error)

func (*Repository) Message added in v1.41.0

func (s *Repository) Message(
	ctx context.Context, messageID int64, fetchMessage bool, fetchVote bool, canViewIP bool,
) (*CommentMessage, error)

func (*Repository) MessagePage added in v1.38.0

func (s *Repository) MessagePage(
	ctx context.Context, messageID int64, perPage int32,
) (int64, CommentType, int32, error)

func (*Repository) MessageRowRoute added in v1.41.0

func (s *Repository) MessageRowRoute(
	ctx context.Context, typeID CommentType, itemID int64, messageID int64,
) ([]string, error)

func (*Repository) MessagesCountFromTimestamp added in v1.37.0

func (s *Repository) MessagesCountFromTimestamp(
	ctx context.Context, typeID CommentType, itemID int64, timestamp time.Time,
) (int32, error)

func (*Repository) MoveMessage

func (s *Repository) MoveMessage(ctx context.Context, commentID int64, dstType CommentType, dstItemID int64) error

func (*Repository) NeedWait added in v1.19.0

func (s *Repository) NeedWait(ctx context.Context, userID int64) (bool, error)

func (*Repository) NotifyAboutReply added in v1.19.0

func (s *Repository) NotifyAboutReply(ctx context.Context, messageID int64) error

func (*Repository) NotifySubscribers added in v1.18.0

func (s *Repository) NotifySubscribers(ctx context.Context, messageID int64) error

func (*Repository) Paginator added in v1.41.0

func (s *Repository) Paginator(request Request) *util.Paginator

func (*Repository) QueueDeleteMessage

func (s *Repository) QueueDeleteMessage(ctx context.Context, commentID int64, byUserID int64) error

func (*Repository) RefreshRepliesCount added in v1.18.0

func (s *Repository) RefreshRepliesCount(ctx context.Context) (int64, error)

func (*Repository) RestoreMessage

func (s *Repository) RestoreMessage(ctx context.Context, commentID int64) error

func (*Repository) SetSubscriptionSent added in v1.41.0

func (s *Repository) SetSubscriptionSent(
	ctx context.Context,
	typeID CommentType,
	itemID int64,
	subscriberID int64,
	sent bool,
) error

func (*Repository) Subscribe

func (s *Repository) Subscribe(ctx context.Context, userID int64, commentsType CommentType, itemID int64) error

func (*Repository) TopicStat added in v1.37.0

func (s *Repository) TopicStat(ctx context.Context, typeID CommentType, itemID int64) (int32, error)

func (*Repository) TopicStatForUser added in v1.37.0

func (s *Repository) TopicStatForUser(
	ctx context.Context, typeID CommentType, itemID int64, userID int64,
) (int32, int32, error)

func (*Repository) UnSubscribe

func (s *Repository) UnSubscribe(ctx context.Context, userID int64, commentsType CommentType, itemID int64) error

func (*Repository) UpdateMessageRepliesCount added in v1.18.0

func (s *Repository) UpdateMessageRepliesCount(ctx context.Context, messageID int64) error

func (*Repository) UpdateTopicView added in v1.18.0

func (s *Repository) UpdateTopicView(ctx context.Context, typeID CommentType, itemID int64, userID int64) error

func (*Repository) UserVote added in v1.41.0

func (s *Repository) UserVote(ctx context.Context, userID int64, commentID int64) (int32, error)

func (*Repository) View

func (s *Repository) View(ctx context.Context, userID int64, commentsType CommentType, itemID int64) error

func (*Repository) VoteComment

func (s *Repository) VoteComment(ctx context.Context, userID int64, commentID int64, vote int32) (int32, error)

type Request added in v1.41.0

type Request struct {
	ItemID             int64
	TypeID             CommentType
	ParentID           int64
	NoParents          bool
	UserID             int64
	Order              []exp.OrderedExpression
	ModeratorAttention ModeratorAttention
	PicturesOfItemID   int64
	FetchMessage       bool
	FetchVote          bool
	FetchIP            bool
	PerPage            int32
	Page               int32
}

Jump to

Keyboard shortcuts

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