37
37
use App \Models \Core \Configs ;
38
38
use App \Models \Core \FrameConfig ;
39
39
40
+ use App \Enums \SendMailTiming ;
41
+
40
42
use App \Plugins \PluginBase ;
41
43
42
44
use App \Traits \ConnectCommonTrait ;
@@ -970,8 +972,10 @@ public function sendRelateNotice($post, $mail_users, $show_method)
970
972
971
973
/**
972
974
* 削除通知の送信
975
+ *
976
+ * $timing = 1:スケジュール送信(非同期送信、デフォルト), 0:即時送信(同期送信)
973
977
*/
974
- public function sendDeleteNotice ($ post , $ show_method , $ delete_comment )
978
+ public function sendDeleteNotice ($ post , $ show_method , $ delete_comment, $ timing = SendMailTiming::async )
975
979
{
976
980
// buckets がない場合
977
981
if (empty ($ this ->buckets )) {
@@ -994,18 +998,19 @@ public function sendDeleteNotice($post, $show_method, $delete_comment)
994
998
return ;
995
999
}
996
1000
997
- // // 送信方法の確認
1001
+ // 送信方法の確認
998
1002
// if ($bucket_mail->timing == 0) {
999
- // // 即時送信
1000
- // dispatch_now(new DeleteNoticeJob($this->frame, $this->buckets, $post, $show_method, $delete_comment));
1001
- // } else {
1002
- // // スケジュール送信
1003
- // DeleteNoticeJob::dispatch($this->frame, $this->buckets, $post, $show_method, $delete_comment);
1004
- // }
1005
- DeleteNoticeJob::dispatch ($ this ->frame , $ this ->buckets , $ post , $ show_method , $ delete_comment );
1003
+ if ( $ timing == SendMailTiming::sync) {
1004
+ // 同期送信
1005
+ // (物理削除時は、非同期だとメール送信前にデータが消えてしまいModelNotFoundExceptionエラーになるため、同期でメール送信)
1006
+ dispatch_now ( new DeleteNoticeJob ( $ this -> frame , $ this -> buckets , $ post , $ show_method , $ delete_comment ));
1007
+ } else {
1008
+ // スケジュール送信
1009
+ DeleteNoticeJob::dispatch ($ this ->frame , $ this ->buckets , $ post , $ show_method , $ delete_comment );
1006
1010
1007
- // 非同期でキューワーカ実行
1008
- $ this ->asyncQueueWork ();
1011
+ // 非同期でキューワーカ実行
1012
+ $ this ->asyncQueueWork ();
1013
+ }
1009
1014
}
1010
1015
1011
1016
/**
0 commit comments