Fix scheduling errors
This commit is contained in:
parent
5c00149e66
commit
f11d12dab3
2 changed files with 7 additions and 7 deletions
|
|
@ -31,10 +31,10 @@ public function __construct()
|
|||
public function handle(): void
|
||||
{
|
||||
// Get the oldest approved article that hasn't been published yet
|
||||
$article = Article::where('is_approved', true)
|
||||
->where('is_valid', true)
|
||||
$article = Article::where('approval_status', 'approved')
|
||||
->whereNotNull('validated_at')
|
||||
->whereDoesntHave('articlePublication')
|
||||
->oldest('approved_at')
|
||||
->oldest('validated_at')
|
||||
->first();
|
||||
|
||||
if (! $article) {
|
||||
|
|
@ -45,7 +45,7 @@ public function handle(): void
|
|||
'article_id' => $article->id,
|
||||
'title' => $article->title,
|
||||
'url' => $article->url,
|
||||
'approved_at' => $article->approved_at
|
||||
'validated_at' => $article->validated_at
|
||||
]);
|
||||
|
||||
// Fetch article data
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Listeners;
|
||||
|
||||
use App\Events\NewArticleFetched;
|
||||
use App\Events\ArticleReadyToPublish;
|
||||
use App\Events\ArticleApproved;
|
||||
use App\Models\Setting;
|
||||
use App\Services\Article\ValidationService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
|
@ -37,12 +37,12 @@ public function handle(NewArticleFetched $event): void
|
|||
if (Setting::isPublishingApprovalsEnabled()) {
|
||||
// If approvals are enabled, only proceed if article is approved
|
||||
if ($article->isApproved()) {
|
||||
event(new ArticleReadyToPublish($article));
|
||||
event(new ArticleApproved($article));
|
||||
}
|
||||
// If not approved, article will wait for manual approval
|
||||
} else {
|
||||
// If approvals are disabled, proceed with publishing
|
||||
event(new ArticleReadyToPublish($article));
|
||||
event(new ArticleApproved($article));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue