diff --git a/conf/artalk.example.simple.yml b/conf/artalk.example.simple.yml index 246b2449d..18d0bf5fe 100644 --- a/conf/artalk.example.simple.yml +++ b/conf/artalk.example.simple.yml @@ -102,6 +102,7 @@ email: account_name: "noreply@example.com" admin_notify: notify_tpl: "default" + notify_pending: false noise_mode: false email: enabled: true diff --git a/conf/artalk.example.yml b/conf/artalk.example.yml index 86a1255e5..e20dadaf2 100644 --- a/conf/artalk.example.yml +++ b/conf/artalk.example.yml @@ -218,6 +218,8 @@ email: admin_notify: # Notification template (set to file path to use custom template) notify_tpl: "default" + # Pending comment still send notification (notifications are still sent when comments are intercepted) + notify_pending: false # Noise mode # -- noise_mode is disabled by default. -- # -- When this option is set to `false`, only messages sent to the administrator will be notified, -- diff --git a/conf/artalk.example.zh-CN.yml b/conf/artalk.example.zh-CN.yml index 30833e2b5..2c13f0802 100644 --- a/conf/artalk.example.zh-CN.yml +++ b/conf/artalk.example.zh-CN.yml @@ -226,6 +226,8 @@ email: admin_notify: # 通知模版 (填入文件路径使用自定义模板) notify_tpl: "default" + # 待审评论仍然发送通知 (当评论被拦截时仍然发送通知) + notify_pending: false # 嘈杂模式 noise_mode: false # 邮件通知管理员 diff --git a/docs/docs/guide/backend/admin_notify.md b/docs/docs/guide/backend/admin_notify.md index 08cd05629..9077b5871 100644 --- a/docs/docs/guide/backend/admin_notify.md +++ b/docs/docs/guide/backend/admin_notify.md @@ -229,6 +229,15 @@ admin_notify: 可用变量和邮件模板相同,可参考:[邮件模版](./email.md#邮件模板) +## 待审评论仍然发送通知 `notify_pending` + +```yaml +admin_notify: + notify_pending: false +``` + +`notify_pending` 默认为关闭状态,当该项设置为 `false` 时,待审评论不会发送通知。你可以在控制中心查看所有待审核的评论。 + ## 嘈杂模式 `noise_mode` ```yaml @@ -236,7 +245,7 @@ admin_notify: noise_mode: false ``` -noise_mode 默认为关闭状态,当该项设置为 `false` 时,站内仅向管理员回复的消息会发送通知,例如「普通用户 A」回复「普通用户 B」,这两个用户之间的通讯不会通知管理员。 +`noise_mode` 默认为关闭状态,当该项设置为 `false` 时,站内仅向管理员回复的消息会发送通知,例如「普通用户 A」回复「普通用户 B」,这两个用户之间的通讯不会通知管理员。 注:当 `moderator.pending_default` 为 `true` 时,noise_mode 为始终开启状态。 diff --git a/i18n/en.yml b/i18n/en.yml index 383c27632..1c296db16 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -40,6 +40,7 @@ "Password update failed": "Password updated": "Password": +"Pending": "Please review": "Retype {{name}}": "Save failed": diff --git a/i18n/zh-CN.yml b/i18n/zh-CN.yml index fa536af4c..277b00fd7 100644 --- a/i18n/zh-CN.yml +++ b/i18n/zh-CN.yml @@ -40,6 +40,7 @@ "Password update failed": 密码修改失败 "Password updated": 密码已修改 "Password": 密码 +"Pending": 待审核 "Please review": 请过目 "Retype {{name}}": 重新输入{{name}} "Save failed": 保存失败 diff --git a/i18n/zh-TW.yml b/i18n/zh-TW.yml index e7c14e1fb..68e9215ad 100644 --- a/i18n/zh-TW.yml +++ b/i18n/zh-TW.yml @@ -40,6 +40,7 @@ "Password update failed": 密碼修改失敗 "Password updated": 密碼已修改 "Password": 密碼 +"Pending": 待審核 "Please review": 請過目 "Retype {{name}}": 重新輸入{{name}} "Save failed": 保存失敗 diff --git a/internal/config/config.go b/internal/config/config.go index b986683b3..8e1808031 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -291,6 +291,7 @@ type AdminNotifyConf struct { Slack NotifySlackConf `koanf:"slack" json:"slack"` // slack LINE NotifyLINEConf `koanf:"line" json:"line"` // LINE WebHook NotifyWebHookConf `koanf:"webhook" json:"webhook"` // WebHook + NotifyPending bool `koanf:"notify_pending" json:"notify_pending"` // 待审核评论通知 NoiseMode bool `koanf:"noise_mode" json:"noise_mode"` // 嘈杂模式 (非回复管理员的评论也发送通知) } diff --git a/internal/notify_pusher/checker.go b/internal/notify_pusher/checker.go index 586be416d..4599b54f0 100644 --- a/internal/notify_pusher/checker.go +++ b/internal/notify_pusher/checker.go @@ -34,6 +34,11 @@ func (pusher *NotifyPusher) checkNeedSendEmailToAdmin(comment *entity.Comment, p return false } + // 待审评论不发送通知 + if comment.IsPending && !pusher.conf.NotifyPending { + return false + } + // 管理员自己回复自己,不提醒 if comment.UserID == admin.ID { return false @@ -73,6 +78,11 @@ func (pusher *NotifyPusher) checkNeedMultiPush(comment *entity.Comment, pComment return false } + // 待审评论不发送通知 + if comment.IsPending && !pusher.conf.NotifyPending { + return false + } + // 非嘈杂模式 if !pusher.conf.NoiseMode { // 如果不是 root 评论 且 回复目标不是管理员,直接忽略 diff --git a/internal/notify_pusher/email.go b/internal/notify_pusher/email.go index 4cd05203c..07a17036d 100644 --- a/internal/notify_pusher/email.go +++ b/internal/notify_pusher/email.go @@ -10,7 +10,6 @@ func (pusher *NotifyPusher) sendEmail(notify *entity.Notify) { if pusher.conf.EmailPush != nil { pusher.conf.EmailPush(notify) } - // email.AsyncSend(¬ify) } func (pusher *NotifyPusher) emailToUser(comment *entity.Comment, pComment *entity.Comment) { diff --git a/internal/notify_pusher/multi.go b/internal/notify_pusher/multi.go index e7ef9a7ae..b8b859e14 100644 --- a/internal/notify_pusher/multi.go +++ b/internal/notify_pusher/multi.go @@ -5,6 +5,7 @@ import ( "time" "github.com/ArtalkJS/Artalk/internal/entity" + "github.com/ArtalkJS/Artalk/internal/i18n" "github.com/ArtalkJS/Artalk/internal/log" "github.com/ArtalkJS/Artalk/internal/notify_pusher/sender" "github.com/ArtalkJS/Artalk/internal/template" @@ -65,7 +66,7 @@ func (pusher *NotifyPusher) getAdminNotifySubjectBody(comment *entity.Comment, t body := render.Render(¬ify) if comment.IsPending { - body = "[待审状态评论]\n\n" + body + body = "[" + i18n.T("Pending") + "]\n\n" + body } return subject, body diff --git a/internal/notify_pusher/operate.go b/internal/notify_pusher/operate.go index 16969e231..21bf74747 100644 --- a/internal/notify_pusher/operate.go +++ b/internal/notify_pusher/operate.go @@ -7,7 +7,6 @@ import ( // 通知发送 (from comment to parentComment) func (pusher *NotifyPusher) Push(comment *entity.Comment, pComment *entity.Comment) { isRootComment := pComment == nil || pComment.IsEmpty() - isAdminNoiseModeOn := pusher.conf.NoiseMode // ============== // 邮件回复对方 @@ -19,7 +18,7 @@ func (pusher *NotifyPusher) Push(comment *entity.Comment, pComment *entity.Comme // ============== // 邮件通知管理员 // ============== - if isRootComment || isAdminNoiseModeOn { + if isRootComment || pusher.conf.NoiseMode { pusher.emailToAdmins(comment, pComment) }