增加回复可见功能
This commit is contained in:
@@ -875,8 +875,13 @@ func (h *Handlers) APIPostDetail(c *gin.Context) {
|
||||
}
|
||||
// 出口再消毒:兼容库内历史脏 HTML(如 <style>),避免旧帖污染整页
|
||||
post.Content = service.SanitizePostHTML(post.Content)
|
||||
hasReplied := uid > 0 && h.Comment.HasUserReplied(uint(id), uid)
|
||||
if uid == 0 {
|
||||
post.Content = service.RedactMembersOnlyHTML(post.Content)
|
||||
post.Content = service.RedactReplyOnlyHTML(post.Content)
|
||||
} else if !isAdmin && post.UserID != uid && !hasReplied {
|
||||
// 作者与管理员始终可见;其他用户需已回复
|
||||
post.Content = service.RedactReplyOnlyHTML(post.Content)
|
||||
}
|
||||
comments, _ := h.Comment.ListByPost(uint(id), uid, isAdmin, post.UserID, h.parseGuestCommentIDs(c))
|
||||
canEdit := h.Post.CanUserEdit(post, uid, isAdmin)
|
||||
@@ -886,13 +891,14 @@ func (h *Handlers) APIPostDetail(c *gin.Context) {
|
||||
}
|
||||
isEdited := post.UpdatedAt.Sub(post.CreatedAt) > time.Minute
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"post": post,
|
||||
"comment_count": len(comments),
|
||||
"liked": h.Post.IsLiked(uid, uint(id)),
|
||||
"favorited": h.Post.IsFavorited(uid, uint(id)),
|
||||
"can_edit": canEdit,
|
||||
"edit_block_reason": editReason,
|
||||
"is_edited": isEdited,
|
||||
"post": post,
|
||||
"comment_count": len(comments),
|
||||
"liked": h.Post.IsLiked(uid, uint(id)),
|
||||
"favorited": h.Post.IsFavorited(uid, uint(id)),
|
||||
"has_replied": hasReplied,
|
||||
"can_edit": canEdit,
|
||||
"edit_block_reason": editReason,
|
||||
"is_edited": isEdited,
|
||||
"post_edit_window_hours": h.Settings.PostEditWindowHours(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ func (h *Handlers) buildSPAPageMeta(c *gin.Context, path string, brand service.S
|
||||
|
||||
func (h *Handlers) postPageMeta(base, siteName, defaultImage string, post *model.Post) *embed_static.SPAPageMeta {
|
||||
permalink := h.Settings.Permalink()
|
||||
content := service.RedactMembersOnlyHTML(post.Content)
|
||||
content := service.RedactGatedPostHTML(post.Content)
|
||||
plain := post.ContentPlain
|
||||
if plain == "" {
|
||||
plain = service.StripHTMLForSearch(content)
|
||||
|
||||
@@ -107,7 +107,7 @@ func (h *Handlers) botHomeHTML(meta *embed_static.SPAPageMeta, brand service.Sit
|
||||
|
||||
func (h *Handlers) botPostHTML(base, siteName, defaultImage, keywords string, post *model.Post) string {
|
||||
meta := attachSiteSEO(h.postPageMeta(base, siteName, defaultImage, post), siteName, keywords)
|
||||
content := service.SanitizePostHTML(service.RedactMembersOnlyHTML(post.Content))
|
||||
content := service.SanitizePostHTML(service.RedactGatedPostHTML(post.Content))
|
||||
author := service.DisplayName(&post.User)
|
||||
var body strings.Builder
|
||||
body.WriteString("<article>")
|
||||
|
||||
Reference in New Issue
Block a user