Fix scheduling errors

This commit is contained in:
myrmidex 2025-08-12 20:55:57 +02:00
parent 5c00149e66
commit f11d12dab3
2 changed files with 7 additions and 7 deletions

View file

@ -31,10 +31,10 @@ public function __construct()
public function handle(): void public function handle(): void
{ {
// Get the oldest approved article that hasn't been published yet // Get the oldest approved article that hasn't been published yet
$article = Article::where('is_approved', true) $article = Article::where('approval_status', 'approved')
->where('is_valid', true) ->whereNotNull('validated_at')
->whereDoesntHave('articlePublication') ->whereDoesntHave('articlePublication')
->oldest('approved_at') ->oldest('validated_at')
->first(); ->first();
if (! $article) { if (! $article) {
@ -45,7 +45,7 @@ public function handle(): void
'article_id' => $article->id, 'article_id' => $article->id,
'title' => $article->title, 'title' => $article->title,
'url' => $article->url, 'url' => $article->url,
'approved_at' => $article->approved_at 'validated_at' => $article->validated_at
]); ]);
// Fetch article data // Fetch article data

View file

@ -3,7 +3,7 @@
namespace App\Listeners; namespace App\Listeners;
use App\Events\NewArticleFetched; use App\Events\NewArticleFetched;
use App\Events\ArticleReadyToPublish; use App\Events\ArticleApproved;
use App\Models\Setting; use App\Models\Setting;
use App\Services\Article\ValidationService; use App\Services\Article\ValidationService;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
@ -37,12 +37,12 @@ public function handle(NewArticleFetched $event): void
if (Setting::isPublishingApprovalsEnabled()) { if (Setting::isPublishingApprovalsEnabled()) {
// If approvals are enabled, only proceed if article is approved // If approvals are enabled, only proceed if article is approved
if ($article->isApproved()) { if ($article->isApproved()) {
event(new ArticleReadyToPublish($article)); event(new ArticleApproved($article));
} }
// If not approved, article will wait for manual approval // If not approved, article will wait for manual approval
} else { } else {
// If approvals are disabled, proceed with publishing // If approvals are disabled, proceed with publishing
event(new ArticleReadyToPublish($article)); event(new ArticleApproved($article));
} }
} }
} }