fedi-feed-router/backend/app/Console/Commands/SyncChannelPostsCommand.php

35 lines
811 B
PHP
Raw Normal View History

2025-06-30 19:54:43 +02:00
<?php
namespace App\Console\Commands;
2025-08-15 16:39:18 +02:00
use Domains\Platform\Jobs\SyncChannelPostsJob;
2025-06-30 19:54:43 +02:00
use Illuminate\Console\Command;
class SyncChannelPostsCommand extends Command
{
protected $signature = 'channel:sync {platform=lemmy}';
2025-07-05 18:26:04 +02:00
2025-06-30 19:54:43 +02:00
protected $description = 'Manually sync channel posts for a platform';
public function handle(): int
{
$platform = $this->argument('platform');
2025-07-05 18:26:04 +02:00
2025-06-30 19:54:43 +02:00
if ($platform === 'lemmy') {
return $this->syncLemmy();
}
2025-07-05 18:26:04 +02:00
2025-06-30 19:54:43 +02:00
$this->error("Unsupported platform: {$platform}");
2025-07-05 18:26:04 +02:00
2025-06-30 19:54:43 +02:00
return self::FAILURE;
}
private function syncLemmy(): int
{
2025-07-05 18:26:04 +02:00
SyncChannelPostsJob::dispatchForAllActiveChannels();
$this->info('Successfully dispatched sync jobs for all active Lemmy channels');
2025-06-30 19:54:43 +02:00
2025-07-05 18:26:04 +02:00
return self::SUCCESS;
2025-06-30 19:54:43 +02:00
}
}