fix: 优化评论发送速度和邮件通知系统
- AI 垃圾评论检测改为异步执行(延迟 2 秒),避免阻塞评论发送
- 站长评论通知改用邮件模板系统发送
- 站长评论通知邮件包含 AI 审核信息(识别结果、理由、识别码)
- 禁用 WordPress 默认的评论通知邮件
- 邮件模板系统支持 Mustache 条件语法({{#variable}}...{{/variable}})
- 评论发送、AI 审核、邮件通知全部异步并行处理
This commit is contained in:
@@ -45,6 +45,21 @@ function argon_send_comment_notify_email($comment) {
|
||||
'comment_date' => get_comment_date(get_option('date_format') . ' ' . get_option('time_format'), $comment),
|
||||
);
|
||||
|
||||
// 检查是否有 AI 审核信息
|
||||
$spam_detection_result = get_comment_meta($comment->comment_ID, '_argon_spam_detection_result', true);
|
||||
if (!empty($spam_detection_result) && is_array($spam_detection_result)) {
|
||||
$vars['ai_spam_check'] = true;
|
||||
$vars['ai_is_spam'] = $spam_detection_result['is_spam'];
|
||||
$vars['ai_spam_reason'] = isset($spam_detection_result['reason']) ? $spam_detection_result['reason'] : '';
|
||||
$vars['ai_spam_action'] = isset($spam_detection_result['action']) ? $spam_detection_result['action'] : '';
|
||||
|
||||
// 生成内容识别码(评论 ID + 时间戳的 MD5)
|
||||
$detection_time = get_comment_meta($comment->comment_ID, '_argon_spam_detection_time', true);
|
||||
$vars['ai_detection_code'] = strtoupper(substr(md5($comment->comment_ID . '-' . $detection_time), 0, 8));
|
||||
} else {
|
||||
$vars['ai_spam_check'] = false;
|
||||
}
|
||||
|
||||
// 发送邮件
|
||||
return argon_send_email($admin_email, 'comment_notify', $vars);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user