Fix publishing system

This commit is contained in:
myrmidex 2025-08-12 01:53:59 +02:00
parent 1b29c3fc13
commit 9d6e20b4f1

View file

@ -6,6 +6,7 @@
use App\Models\Article;
use App\Models\Setting;
use App\Jobs\ArticleDiscoveryJob;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
@ -47,12 +48,12 @@ public function approve(Article $article): JsonResponse
{
try {
$article->approve('manual');
return $this->sendResponse(
new ArticleResource($article->fresh(['feed', 'articlePublication'])),
'Article approved and queued for publishing.'
);
} catch (\Exception $e) {
} catch (Exception $e) {
return $this->sendError('Failed to approve article: ' . $e->getMessage(), [], 500);
}
}
@ -64,12 +65,12 @@ public function reject(Article $article): JsonResponse
{
try {
$article->reject('manual');
return $this->sendResponse(
new ArticleResource($article->fresh(['feed', 'articlePublication'])),
'Article rejected.'
);
} catch (\Exception $e) {
} catch (Exception $e) {
return $this->sendError('Failed to reject article: ' . $e->getMessage(), [], 500);
}
}
@ -80,15 +81,14 @@ public function reject(Article $article): JsonResponse
public function refresh(): JsonResponse
{
try {
// Dispatch the article discovery job
ArticleDiscoveryJob::dispatch();
return $this->sendResponse(
null,
'Article refresh started. New articles will appear shortly.'
);
} catch (\Exception $e) {
} catch (Exception $e) {
return $this->sendError('Failed to start article refresh: ' . $e->getMessage(), [], 500);
}
}
}
}