expire related comments after highlight comment

pull/393/head
Michael Li 1 year ago
parent 405aff2b01
commit e2f34633cf
No known key found for this signature in database

@ -27,6 +27,7 @@ const (
_commentActionReplyDelete _commentActionReplyDelete
_commentActionReplyThumbsUp _commentActionReplyThumbsUp
_commentActionReplyThumbsDown _commentActionReplyThumbsDown
_commentActionHighlight
) )
type cacheUnreadMsgEvent struct { type cacheUnreadMsgEvent struct {
@ -138,6 +139,8 @@ func (e *commentActionEvent) Action() (err error) {
case _commentActionThumbsUp, _commentActionThumbsDown: case _commentActionThumbsUp, _commentActionThumbsDown:
err = e.updateCommentMetric() err = e.updateCommentMetric()
e.expireHotsComments() e.expireHotsComments()
case _commentActionHighlight:
e.expireAllStyleComments()
default: default:
// nothing // nothing
} }

@ -482,6 +482,10 @@ func (s *privSrv) HighlightComment(req *web.HighlightCommentReq) (*web.Highlight
} else if err != nil { } else if err != nil {
return nil, web.ErrHighlightCommentFailed return nil, web.ErrHighlightCommentFailed
} }
// 缓存处理, 宽松处理错误
if comment, err := s.Ds.GetCommentByID(req.CommentId); err == nil {
onCommentActionEvent(comment.PostID, comment.ID, _commentActionHighlight)
}
return &web.HighlightCommentResp{ return &web.HighlightCommentResp{
HighlightStatus: status, HighlightStatus: status,
}, nil }, nil

Loading…
Cancel
Save