Skip to content

Commit 20258b2

Browse files
committed
bugfix: データベース, 削除のメール通知をONにしてもメールが飛ばないバグ修正のため、削除時は同期送信するよう対応2 #1008
1 parent cc2213b commit 20258b2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

app/Plugins/User/UserPluginBase.php

+16-11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
use App\Models\Core\Configs;
3838
use App\Models\Core\FrameConfig;
3939

40+
use App\Enums\SendMailTiming;
41+
4042
use App\Plugins\PluginBase;
4143

4244
use App\Traits\ConnectCommonTrait;
@@ -970,8 +972,10 @@ public function sendRelateNotice($post, $mail_users, $show_method)
970972

971973
/**
972974
* 削除通知の送信
975+
*
976+
* $timing = 1:スケジュール送信(非同期送信、デフォルト), 0:即時送信(同期送信)
973977
*/
974-
public function sendDeleteNotice($post, $show_method, $delete_comment)
978+
public function sendDeleteNotice($post, $show_method, $delete_comment, $timing = SendMailTiming::async)
975979
{
976980
// buckets がない場合
977981
if (empty($this->buckets)) {
@@ -994,18 +998,19 @@ public function sendDeleteNotice($post, $show_method, $delete_comment)
994998
return;
995999
}
9961000

997-
// // 送信方法の確認
1001+
// 送信方法の確認
9981002
// 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);
10061010

1007-
// 非同期でキューワーカ実行
1008-
$this->asyncQueueWork();
1011+
// 非同期でキューワーカ実行
1012+
$this->asyncQueueWork();
1013+
}
10091014
}
10101015

10111016
/**

0 commit comments

Comments
 (0)