diff --git a/internal/servants/web/events.go b/internal/servants/web/events.go index 82db8c9d..d5346226 100644 --- a/internal/servants/web/events.go +++ b/internal/servants/web/events.go @@ -27,6 +27,7 @@ const ( _commentActionReplyDelete _commentActionReplyThumbsUp _commentActionReplyThumbsDown + _commentActionHighlight ) type cacheUnreadMsgEvent struct { @@ -138,6 +139,8 @@ func (e *commentActionEvent) Action() (err error) { case _commentActionThumbsUp, _commentActionThumbsDown: err = e.updateCommentMetric() e.expireHotsComments() + case _commentActionHighlight: + e.expireAllStyleComments() default: // nothing } diff --git a/internal/servants/web/priv.go b/internal/servants/web/priv.go index 322cf0c0..1a4a5f4a 100644 --- a/internal/servants/web/priv.go +++ b/internal/servants/web/priv.go @@ -482,6 +482,10 @@ func (s *privSrv) HighlightComment(req *web.HighlightCommentReq) (*web.Highlight } else if err != nil { return nil, web.ErrHighlightCommentFailed } + // 缓存处理, 宽松处理错误 + if comment, err := s.Ds.GetCommentByID(req.CommentId); err == nil { + onCommentActionEvent(comment.PostID, comment.ID, _commentActionHighlight) + } return &web.HighlightCommentResp{ HighlightStatus: status, }, nil