93 lines
2.0 KiB
Go
93 lines
2.0 KiB
Go
package entity
|
|
|
|
// Kind is moment_posts.kind.
|
|
type Kind int16
|
|
|
|
const (
|
|
KindText Kind = 1
|
|
KindImage Kind = 2
|
|
KindVideo Kind = 3
|
|
)
|
|
|
|
func (k Kind) Valid() bool {
|
|
return k == KindText || k == KindImage || k == KindVideo
|
|
}
|
|
|
|
// Visibility is moment_posts.visibility.
|
|
type Visibility int16
|
|
|
|
const (
|
|
VisibilityFriends Visibility = 0
|
|
VisibilityPrivate Visibility = 1
|
|
VisibilityInclude Visibility = 2
|
|
VisibilityExclude Visibility = 3
|
|
)
|
|
|
|
func (v Visibility) Valid() bool {
|
|
return v >= VisibilityFriends && v <= VisibilityExclude
|
|
}
|
|
|
|
func (v Visibility) NeedsAudience() bool {
|
|
return v == VisibilityInclude || v == VisibilityExclude
|
|
}
|
|
|
|
// Status is moment_posts.status / moment_comments.status.
|
|
type Status int16
|
|
|
|
const (
|
|
StatusNormal Status = 0
|
|
StatusDeleted Status = 1
|
|
)
|
|
|
|
func (s Status) Valid() bool {
|
|
return s == StatusNormal || s == StatusDeleted
|
|
}
|
|
|
|
// NoticeKind is moment_notices.kind.
|
|
type NoticeKind int16
|
|
|
|
const (
|
|
NoticeLike NoticeKind = 1
|
|
NoticeComment NoticeKind = 2
|
|
NoticeReply NoticeKind = 3
|
|
)
|
|
|
|
func (k NoticeKind) Valid() bool {
|
|
return k == NoticeLike || k == NoticeComment || k == NoticeReply
|
|
}
|
|
|
|
// VisibleDays is moment_settings.visible_days.
|
|
type VisibleDays int
|
|
|
|
const (
|
|
VisibleAll VisibleDays = 0
|
|
Visible3Days VisibleDays = 3
|
|
Visible30Days VisibleDays = 30
|
|
Visible180Days VisibleDays = 180
|
|
MaxAudience = 200
|
|
MaxImages = 9
|
|
MaxTextRunes = 1000
|
|
MaxCommentRunes = 500
|
|
MaxVideoMS = 30_000
|
|
ListDefault = 20
|
|
ListMax = 50
|
|
Overfetch = 50
|
|
OverfetchRounds = 3
|
|
LikePreviewMax = 10
|
|
CommentPreviewMax = 20
|
|
)
|
|
|
|
func (d VisibleDays) Valid() bool {
|
|
return d == VisibleAll || d == Visible3Days || d == Visible30Days || d == Visible180Days
|
|
}
|
|
|
|
func ClampLimit(limit int) int {
|
|
if limit <= 0 {
|
|
return ListDefault
|
|
}
|
|
if limit > ListMax {
|
|
return ListMax
|
|
}
|
|
return limit
|
|
}
|