From 9d6e20b4f1c153c93ac6dea2fe32daf28caaad1c Mon Sep 17 00:00:00 2001 From: myrmidex Date: Tue, 12 Aug 2025 01:53:59 +0200 Subject: [PATCH] Fix publishing system --- .../Controllers/Api/V1/ArticlesController.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/app/Http/Controllers/Api/V1/ArticlesController.php b/backend/app/Http/Controllers/Api/V1/ArticlesController.php index e13b323..a1606c6 100644 --- a/backend/app/Http/Controllers/Api/V1/ArticlesController.php +++ b/backend/app/Http/Controllers/Api/V1/ArticlesController.php @@ -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); } } -} \ No newline at end of file +}