diff --git a/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java index 6f4c197..2e7b044 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java @@ -81,18 +81,20 @@ public class CommentServiceImpl extends AbstractService implements Comm commentSharpUrl.append("/comment/").append(comment.getIdComment()); commentMapper.updateCommentSharpUrl(comment.getIdComment(), commentSharpUrl.toString()); - String commentContent = comment.getCommentContent(); - if(StringUtils.isNotBlank(commentContent)){ - Integer length = commentContent.length(); - if(length > MAX_PREVIEW){ - length = 200; + // 评论者不是作者本人则进行消息通知 + if (!article.getArticleAuthorId().equals(comment.getCommentAuthorId())) { + String commentContent = comment.getCommentContent(); + if(StringUtils.isNotBlank(commentContent)){ + Integer length = commentContent.length(); + if(length > MAX_PREVIEW){ + length = 200; + } + String commentPreviewContent = commentContent.substring(0,length); + commentContent = Html2TextUtil.getContent(commentPreviewContent); + NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent); } - String commentPreviewContent = commentContent.substring(0,length); - commentContent = Html2TextUtil.getContent(commentPreviewContent); } - NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent); - return map; } }