feat(posts): add post reference/internal linking functionality
All checks were successful
Build Backend / build (push) Successful in 2m19s
Build Backend / build-docker (push) Successful in 1m18s

Add support for referencing other posts within messages through a new post_ref segment type. Includes new PostReference model to track relationships, PostRefService for processing references, and new endpoints for post suggestions, related posts, and reference click tracking.
This commit is contained in:
lafay
2026-04-26 00:37:20 +08:00
parent 898c0e6d9c
commit 23d7f1151e
11 changed files with 592 additions and 5 deletions

View File

@@ -250,8 +250,9 @@ const (
SegmentTypeAt SegmentType = "at"
SegmentTypeReply SegmentType = "reply"
SegmentTypeFace SegmentType = "face"
SegmentTypeLink SegmentType = "link"
SegmentTypeVote SegmentType = "vote"
SegmentTypeLink SegmentType = "link"
SegmentTypeVote SegmentType = "vote"
SegmentTypePostRef SegmentType = "post_ref"
)
// TextSegmentData 文本数据
@@ -325,6 +326,23 @@ type VoteOptionData struct {
Content string `json:"content"`
}
// PostRefSegmentData 帖子内链Segment数据
type PostRefSegmentData struct {
PostID string `json:"post_id"`
Title string `json:"title,omitempty"`
Author *UserResponse `json:"author,omitempty"`
Status string `json:"status,omitempty"`
Accessible bool `json:"accessible"`
ClickCount int `json:"click_count,omitzero"`
}
// PostRefBrief 帖子内链简要信息 (用于搜索联想)
type PostRefBrief struct {
ID string `json:"id"`
Title string `json:"title"`
Channel string `json:"channel,omitempty"`
}
// VoteSegmentData 投票Segment数据
type VoteSegmentData struct {
Options []VoteOptionData `json:"options"`