spark-server/internal/module/square/entity/post.go
DESKTOP-L8OUL9F\gfl0034 53426af122 feat: 多广场 channel、音乐公开 API 与订阅 package_name
支持 square/squarenovel/squaresteps/squarehealth 实例与 category 筛选;音乐增加免登录 grouped/track;订阅套餐按 package_name 区分;补 migration 0030/0031 与 OpenAPI。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-30 09:02:28 +08:00

93 lines
1.8 KiB
Go

package entity
// Post is one square entry.
type Post struct {
ID int64
UserID int64
Channel Channel
Category Category
Kind Kind
Text string
Content []byte
POI POI
Visibility Visibility
AuditStatus AuditStatus
Status Status
Source Source
SourceURL string
ExpiresAtMS int64 // 0 = never expires
LikeCount int
CommentCount int
CreatedAtMS int64
}
// Expired reports whether a bot post has passed expires_at (ms).
func (p *Post) Expired(nowMS int64) bool {
if p == nil || p.ExpiresAtMS <= 0 {
return false
}
if nowMS <= 0 {
return false
}
return nowMS >= p.ExpiresAtMS
}
// POI is an optional location pin.
type POI struct {
Lat float64
Lng float64
Name string
Address string
}
func (p POI) Set() bool {
return p.Name != "" || p.Address != "" || p.Lat != 0 || p.Lng != 0
}
// Like is one (post, user) edge.
type Like struct {
PostID int64
UserID int64
CreatedAtMS int64
}
// Comment is one square comment or reply.
type Comment struct {
ID int64
PostID int64
UserID int64
ReplyToID int64
ReplyToUID int64
Text string
Status Status
CreatedAtMS int64
}
// Notice is a like/comment notification.
type Notice struct {
ID int64
ToUserID int64
Channel Channel
FromUserID int64
Kind NoticeKind
PostID int64
CommentID int64
ReadAtMS int64
CreatedAtMS int64
}
// NoticeState is per-user per-channel read watermark for square notices.
type NoticeState struct {
UserID int64
Channel Channel
LastReadNoticeID int64
UpdatedAtMS int64
}
func DefaultNoticeState(userID int64, channel Channel) *NoticeState {
if channel == "" {
channel = ChannelSquare
}
return &NoticeState{UserID: userID, Channel: channel}
}