1919
2020if (!defined ('__TYPECHO_ROOT_DIR__ ' )) exit ;
2121
22+ require_once 'Log.php ' ;
23+
2224/**
2325 * Plugin
2426 *
@@ -203,6 +205,7 @@ public static function config(\Typecho\Widget\Helper\Form $form)
203205 'to_owner ' => '有评论及回复时, 发邮件通知博主. ' ,
204206 'to_guest ' => '评论被回复时, 发邮件通知评论者. ' ,
205207 'to_me ' => '自己回复自己的评论时, 发邮件通知. (同时针对博主和访客) ' ,
208+ 'isSync ' => '同步发送邮件,否则需要手动(或者用定时任务自动)执行发送任务 ' ,
206209 ],
207210 ['to_owner ' , 'to_guest ' ],
208211 '其他设置 ' ,
@@ -302,8 +305,19 @@ public static function parseComment($comment)
302305 'sent ' => '0 '
303306 ])
304307 );
305- }
306308
309+ // 如果同步就直接发邮件,否则添加至队列
310+ $ keySync = Helper::options ()->plugin ('CommentToMail ' )->key ;
311+ $ optionsSync = Widget::widget ('Widget_Options ' );
312+ $ entryUrlSync = ($ optionsSync ->rewrite ) ? $ optionsSync ->siteUrl : $ optionsSync ->siteUrl . 'index.php ' ; // 博客网址
313+ $ deliverUrlSync = rtrim ($ entryUrlSync , '/ ' ) . '/action/ ' . self ::$ _action . '?do=deliverMail&key= ' . $ keySync ;;
314+
315+ $ isSync = Helper::options ()->plugin ('CommentToMail ' )->other ;
316+ if (in_array ('isSync ' , $ isSync )){
317+ file_get_contents ($ deliverUrlSync );
318+ }
319+ }
320+
307321 /**
308322 * 通过邮件 博主 通过邮件后 回调函数
309323 *
@@ -316,6 +330,7 @@ public static function passComment($comment, $edit, $status)
316330 if ($ status !== 'approved ' ) return ;
317331 $ edit ->status = 'approved ' ;
318332 $ edit ->type = '1 ' ; //标记 approved后的邮件 仅发送给访客 避免重复发送给博主
333+
319334 self ::parseComment ($ edit );
320335 }
321336}
0 commit comments