spark-server/internal/module/square/entity/post.go
DESKTOP-L8OUL9F\gfl0034 715ace7ac6 feat(square): 广场 Bot/RSS 发布与媒体校验
支持广场机器人发帖与媒体类型检查,并补充相关迁移与 i18n。
2026-09-24 23:07:06 +08:00

86 lines
1.6 KiB
Go

package entity
// Post is one square entry.
type Post struct {
ID int64
UserID int64
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
FromUserID int64
Kind NoticeKind
PostID int64
CommentID int64
ReadAtMS int64
CreatedAtMS int64
}
// NoticeState is per-user read watermark for square notices.
type NoticeState struct {
UserID int64
LastReadNoticeID int64
UpdatedAtMS int64
}
func DefaultNoticeState(userID int64) *NoticeState {
return &NoticeState{UserID: userID}
}