From 74fcd2301061e782737282dcd7afa74995ae25f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E5=A4=AA=20=E2=82=8D=E2=82=8D=20=E2=97=9D=28?= =?UTF-8?q?=EF=BD=A5=E2=97=A1=EF=BD=A5=29=E2=97=9F=20=E2=81=BE=E2=81=BE?= Date: Sat, 27 Apr 2024 19:39:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=93=A1=E5=AF=A9=E6=A0=B8=E6=96=87=E7=AB=A0=E6=99=82=E9=96=93?= =?UTF-8?q?=E5=88=A4=E6=96=B7=E9=8C=AF=E8=AA=A4=E7=9A=84=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Cards/ReviewController.php | 148 +++++++++--------- 1 file changed, 73 insertions(+), 75 deletions(-) diff --git a/app/Domains/Social/Http/Controllers/Api/Cards/ReviewController.php b/app/Domains/Social/Http/Controllers/Api/Cards/ReviewController.php index d31d1001..90b40c11 100644 --- a/app/Domains/Social/Http/Controllers/Api/Cards/ReviewController.php +++ b/app/Domains/Social/Http/Controllers/Api/Cards/ReviewController.php @@ -101,84 +101,82 @@ public function voting(Request $request, Cards $card, $status) /** * 如果上一篇通過審核的文章距今已超過 60 分鐘,那就順便發表到社群平台上。 */ - if ($this->delayMode) { - $card = Cards::where('active', 1)->orderBy('updated_at', 'DESC')->first(); - $now = Carbon::now()->subMinutes(60); + $card = Cards::where('active', 1)->orderBy('updated_at', 'DESC')->first(); + $now = Carbon::now()->addMinutes(60); + + if (isset($card) && $now->timestamp > $card->updated_at->timestamp) { + /** + * 先把需要發表的社群平台抓出來 + */ + $platforms = Platform::where('action', Platform::ACTION_PUBLISH) + ->active() + ->get(); - if (isset($card) && $now->timestamp > $card->updated_at->timestamp) { - /** - * 先把需要發表的社群平台抓出來 - */ - $platforms = Platform::where('action', Platform::ACTION_PUBLISH) - ->active() - ->get(); - - /** - * 根據社群平台逐一發佈 - */ - foreach ($platforms as $platform) { - switch ($platform->type) { - /** - * 丟給負責發表文章到 Facebook 的 Job - */ - case Platform::TYPE_FACEBOOK: - dispatch(new FacebookPublishJob($model, $platform))->onQueue('highest'); - break; - - /** - * 丟給負責發表文章到 Twitter 的 Job - */ - case Platform::TYPE_TWITTER: - dispatch(new TwitterPublishJob($model, $platform))->onQueue('highest'); - break; - - /** - * 丟給負責發表文章到 Plurk 的 Job - */ - case Platform::TYPE_PLURK: - dispatch(new PlurkPublishJob($model, $platform))->onQueue('highest'); - break; - - /** - * 丟給負責發表文章到 Discord 的 Job - */ - case Platform::TYPE_DISCORD: - dispatch(new DiscordPublishJob($model, $platform))->onQueue('highest'); - break; - - /** - * 丟給負責發表文章到 Tumblr 的 Job - */ - case Platform::TYPE_TUMBLR: - dispatch(new TumblrPublishJob($model, $platform))->onQueue('highest'); - break; - - /** - * 丟給負責發表文章到 Telegram 的 Job - */ - case Platform::TYPE_TELEGRAM: - dispatch(new TelegramPublishJob($model, $platform))->onQueue('highest'); - break; - - /** - * 丟給負責發表文章到 Bsky 的 Job - */ - case Platform::TYPE_BSKY: - dispatch(new BskyPublishJob($card, $platform))->onQueue('highest'); - break; - + /** + * 根據社群平台逐一發佈 + */ + foreach ($platforms as $platform) { + switch ($platform->type) { + /** + * 丟給負責發表文章到 Facebook 的 Job + */ + case Platform::TYPE_FACEBOOK: + dispatch(new FacebookPublishJob($model, $platform))->onQueue('highest'); + break; + + /** + * 丟給負責發表文章到 Twitter 的 Job + */ + case Platform::TYPE_TWITTER: + dispatch(new TwitterPublishJob($model, $platform))->onQueue('highest'); + break; + + /** + * 丟給負責發表文章到 Plurk 的 Job + */ + case Platform::TYPE_PLURK: + dispatch(new PlurkPublishJob($model, $platform))->onQueue('highest'); + break; + + /** + * 丟給負責發表文章到 Discord 的 Job + */ + case Platform::TYPE_DISCORD: + dispatch(new DiscordPublishJob($model, $platform))->onQueue('highest'); + break; + + /** + * 丟給負責發表文章到 Tumblr 的 Job + */ + case Platform::TYPE_TUMBLR: + dispatch(new TumblrPublishJob($model, $platform))->onQueue('highest'); + break; + + /** + * 丟給負責發表文章到 Telegram 的 Job + */ + case Platform::TYPE_TELEGRAM: + dispatch(new TelegramPublishJob($model, $platform))->onQueue('highest'); + break; + + /** + * 丟給負責發表文章到 Bsky 的 Job + */ + case Platform::TYPE_BSKY: + dispatch(new BskyPublishJob($card, $platform))->onQueue('highest'); + break; + + /** + * 其它並不在支援名單當中的社群 + */ + default: /** - * 其它並不在支援名單當中的社群 + * 直接把資料寫入 Activity log 以便日後查核 */ - default: - /** - * 直接把資料寫入 Activity log 以便日後查核 - */ - activity('social cards - undefined publish') - ->performedOn($card) - ->log(json_encode($model)); - break; - } + activity('social cards - undefined publish') + ->performedOn($card) + ->log(json_encode($model)); + break; } } }