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

28 lines
641 B
PHP
Raw Normal View History

2025-06-29 20:16:25 +02:00
<?php
namespace App\Console\Commands;
2025-06-30 18:18:30 +02:00
use App\Jobs\PublishToLemmyJob;
2025-06-29 20:16:25 +02:00
use App\Models\Article;
use Illuminate\Console\Command;
class PublishToLemmyCommand extends Command
{
protected $signature = 'article:publish-to-lemmy';
2025-06-30 18:18:30 +02:00
protected $description = 'Queue an article for publishing to Lemmy';
2025-06-29 20:16:25 +02:00
public function handle(): int
{
2025-07-06 11:30:38 +02:00
$article = Article::whereDoesntHave('articlePublication')->firstOrFail();
2025-06-29 20:16:25 +02:00
2025-06-30 18:18:30 +02:00
$this->info('Queuing article for publishing: ' . $article->url);
2025-06-29 21:20:45 +02:00
2025-06-30 18:18:30 +02:00
PublishToLemmyJob::dispatch($article);
$this->info('Article queued successfully');
2025-06-29 20:16:25 +02:00
return self::SUCCESS;
}
}