halo icon indicating copy to clipboard operation
halo copied to clipboard

评论邮件发送时机

Open cetr opened this issue 3 years ago • 3 comments

你当前使用的版本

No response

描述一下此特性

目前当新访客给之前访客留的评论追评时,将会直接发送邮件给被追评的访客,即使已开启评论审核,那么就导致已留言的访客有被疯狂轰炸的风险

建议在站长审核通过后再发送邮件给已留言的访客,给站长留言不用改,还是即时通知

附加信息

No response

cetr avatar Jul 15 '22 02:07 cetr

/kind improvement /milestone 1.6.x

/good-first-issue

ruibaby avatar Jul 15 '22 02:07 ruibaby

@ruibaby: This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-good-first-issue command.

In response to this:

/kind improvement /milestone 1.6.x

/good-first-issue

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

f2c-ci-robot[bot] avatar Jul 15 '22 02:07 f2c-ci-robot[bot]

/area core

ruibaby avatar Jul 15 '22 02:07 ruibaby

看了一下代码想了一个不成熟的解决方法: run.halo.app.service.impl.BaseCommentServiceImpl#updateStatus中也 new CommentReplyEvent 然后在run.halo.app.listener.comment.CommentEventListener#handleCommentReplyEvent中判断 CommentStatus 是否为 PUBLISHED 就发送Eamil

具体是在handleCommentReplyEvent:232 加入

if (!postComment.getStatus().equals(CommentStatus.PUBLISHED)) {
    return;
}

run.halo.app.service.impl.BaseCommentServiceImpl#updateStatus:386 加入

 if (!ServiceUtils.isEmptyId(comment.getParentId())) {
     eventPublisher.publishEvent(new CommentReplyEvent(this, comment.getId()));
}

经简单测试基本实现了功能,但是对于未审核的评论没有给到博主本人邮箱提示,可能会是一个新的feature。 如有遗漏没考虑清楚的细节问题请指正,谢谢。

AirboZH avatar Aug 21 '22 17:08 AirboZH

@AirboZH 整体思路没有问题。但是得注意一下,在 updateStatus 这个方法需要先判断是不是待审核状态,如果是,才进行后面的逻辑。否则如果管理员将回收站状态的评论转为发布状态的时候可能也会发送邮件。

ruibaby avatar Aug 22 '22 02:08 ruibaby

@ruibaby 好的谢谢,确实是我忽略的一个点,那我先认领了。 /assign

AirboZH avatar Aug 22 '22 02:08 AirboZH