fedi-feed-router/app/Console/Commands/FetchNewArticlesCommand.php

35 lines
792 B
PHP
Raw Normal View History

2025-06-29 09:37:49 +02:00
<?php
namespace App\Console\Commands;
2025-07-05 18:26:04 +02:00
use App\Jobs\ArticleDiscoveryJob;
2025-07-06 16:51:09 +02:00
use App\Models\Feed;
2025-07-10 11:01:01 +02:00
use App\Models\Setting;
2025-06-29 09:37:49 +02:00
use Illuminate\Console\Command;
class FetchNewArticlesCommand extends Command
{
2025-06-30 18:18:30 +02:00
protected $signature = 'article:refresh';
2025-06-29 09:37:49 +02:00
2025-06-30 18:18:30 +02:00
protected $description = 'Fetches latest articles';
2025-06-29 09:37:49 +02:00
public function handle(): int
{
2025-07-10 11:01:01 +02:00
if (!Setting::isArticleProcessingEnabled()) {
$this->info('Article processing is disabled. Article discovery skipped.');
return self::SUCCESS;
}
2025-07-06 16:51:09 +02:00
if (!Feed::where('is_active', true)->exists()) {
$this->info('No active feeds found. Article discovery skipped.');
return self::SUCCESS;
}
2025-07-05 18:26:04 +02:00
ArticleDiscoveryJob::dispatch();
2025-06-29 09:37:49 +02:00
return self::SUCCESS;
}
}