Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
refactor: remove unused context param from handleApiError across all publishers
Paulo Castellano6c2a3545942f
diff --git a/app/Services/Social/FacebookPublisher.php b/app/Services/Social/FacebookPublisher.phpindex ce0cfa831..55531450a 100644--- a/app/Services/Social/FacebookPublisher.php+++ b/app/Services/Social/FacebookPublisher.php@@ -77,7 +77,7 @@ class FacebookPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$data = $response->json();@@ -104,7 +104,7 @@ class FacebookPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$data = $response->json();@@ -170,7 +170,7 @@ class FacebookPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$data = $response->json();@@ -198,7 +198,7 @@ class FacebookPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$data = $response->json();@@ -225,7 +225,7 @@ class FacebookPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$data = $response->json();@@ -242,7 +242,7 @@ class FacebookPublisherLog::error('Facebook reel upload transfer failed', ['body' => $uploadResponse->body(),]);- $this->handleApiError($uploadResponse, 'Facebook API error');+ $this->handleApiError($uploadResponse);}// Finish and publish the reel@@ -258,7 +258,7 @@ class FacebookPublisherLog::error('Facebook reel finish failed', ['body' => $finishResponse->body(),]);- $this->handleApiError($finishResponse, 'Facebook API error');+ $this->handleApiError($finishResponse);}$finishData = $finishResponse->json();@@ -284,7 +284,7 @@ class FacebookPublisher]);if ($response->failed()) {- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$videoId = $response->json()['video_id'];@@ -304,7 +304,7 @@ class FacebookPublisher]);if ($finishResponse->failed()) {- $this->handleApiError($finishResponse, 'Facebook API error');+ $this->handleApiError($finishResponse);}$storyId = $finishResponse->json()['post_id'] ?? $videoId;@@ -325,7 +325,7 @@ class FacebookPublisherLog::error('Facebook photo story failed', ['body' => $response->body(),]);- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}$storyId = $response->json()['post_id'] ?? $response->json()['id'];@@ -345,13 +345,13 @@ class FacebookPublisher]);if ($response->failed()) {- $this->handleApiError($response, 'Facebook API error');+ $this->handleApiError($response);}return $response->json()['id'];}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw FacebookPublishException::fromApiResponse($response);}diff --git a/app/Services/Social/LinkedInPagePublisher.php b/app/Services/Social/LinkedInPagePublisher.phpindex 21c5575cc..a1ce5cb69 100644--- a/app/Services/Social/LinkedInPagePublisher.php+++ b/app/Services/Social/LinkedInPagePublisher.php@@ -132,7 +132,7 @@ class LinkedInPagePublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'LinkedIn Page API error');+ $this->handleApiError($response);}$postId = $response->header('x-restli-id');@@ -205,7 +205,7 @@ class LinkedInPagePublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'LinkedIn Page API error');+ $this->handleApiError($response);}$postId = $response->header('x-restli-id');@@ -264,7 +264,7 @@ class LinkedInPagePublisherif ($initResponse->failed()) {Log::error('LinkedIn Page image init failed', ['body' => $initResponse->body()]);- $this->handleApiError($initResponse, 'Failed to initialize LinkedIn Page image upload');+ $this->handleApiError($initResponse);}$initData = $initResponse->json();@@ -302,7 +302,7 @@ class LinkedInPagePublisherif ($uploadResponse->failed()) {Log::error('LinkedIn Page image upload failed', ['body' => $uploadResponse->body()]);- $this->handleApiError($uploadResponse, 'Failed to upload LinkedIn Page image');+ $this->handleApiError($uploadResponse);}Log::info('LinkedIn Page image upload success', ['imageUrn' => $imageUrn]);@@ -348,7 +348,7 @@ class LinkedInPagePublisherif ($initResponse->failed()) {Log::error('LinkedIn Page video init failed', ['body' => $initResponse->body()]);- $this->handleApiError($initResponse, 'Failed to initialize LinkedIn Page video upload');+ $this->handleApiError($initResponse);}$initData = $initResponse->json();@@ -399,7 +399,7 @@ class LinkedInPagePublisher'index' => $index,'body' => $chunkResponse->body(),]);- $this->handleApiError($chunkResponse, 'Failed to upload LinkedIn Page video chunk');+ $this->handleApiError($chunkResponse);}$etag = $chunkResponse->header('etag');@@ -424,7 +424,7 @@ class LinkedInPagePublisherif ($finalizeResponse->failed()) {Log::error('LinkedIn Page video finalize failed', ['body' => $finalizeResponse->body()]);- $this->handleApiError($finalizeResponse, 'Failed to finalize LinkedIn Page video upload');+ $this->handleApiError($finalizeResponse);}Log::info('LinkedIn Page video upload finalized', ['videoUrn' => $videoUrn]);@@ -483,7 +483,7 @@ class LinkedInPagePublisher]);if ($response->failed()) {- $this->handleApiError($response, 'Failed to refresh LinkedIn Page token');+ $this->handleApiError($response);}$data = $response->json();@@ -498,7 +498,7 @@ class LinkedInPagePublisherapp(LinkedInTokenSynchronizer::class)->syncTokens($account);}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw LinkedInPublishException::fromApiResponse($response);}diff --git a/app/Services/Social/LinkedInPublisher.php b/app/Services/Social/LinkedInPublisher.phpindex 23dd3d5df..be659ca1f 100644--- a/app/Services/Social/LinkedInPublisher.php+++ b/app/Services/Social/LinkedInPublisher.php@@ -125,7 +125,7 @@ class LinkedInPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'LinkedIn API error');+ $this->handleApiError($response);}$postId = $response->header('x-restli-id');@@ -192,7 +192,7 @@ class LinkedInPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'LinkedIn API error');+ $this->handleApiError($response);}$postId = $response->header('x-restli-id');@@ -245,7 +245,7 @@ class LinkedInPublisherif ($initResponse->failed()) {Log::error('LinkedIn image init failed', ['body' => $initResponse->body()]);- $this->handleApiError($initResponse, 'Failed to initialize LinkedIn image upload');+ $this->handleApiError($initResponse);}$initData = $initResponse->json();@@ -283,7 +283,7 @@ class LinkedInPublisherif ($uploadResponse->failed()) {Log::error('LinkedIn image upload failed', ['body' => $uploadResponse->body()]);- $this->handleApiError($uploadResponse, 'Failed to upload LinkedIn image');+ $this->handleApiError($uploadResponse);}Log::info('LinkedIn image upload success', ['imageUrn' => $imageUrn]);@@ -329,7 +329,7 @@ class LinkedInPublisherif ($initResponse->failed()) {Log::error('LinkedIn video init failed', ['body' => $initResponse->body()]);- $this->handleApiError($initResponse, 'Failed to initialize LinkedIn video upload');+ $this->handleApiError($initResponse);}$initData = $initResponse->json();@@ -380,7 +380,7 @@ class LinkedInPublisher'index' => $index,'body' => $chunkResponse->body(),]);- $this->handleApiError($chunkResponse, 'Failed to upload LinkedIn video chunk');+ $this->handleApiError($chunkResponse);}$etag = $chunkResponse->header('etag');@@ -405,7 +405,7 @@ class LinkedInPublisherif ($finalizeResponse->failed()) {Log::error('LinkedIn video finalize failed', ['body' => $finalizeResponse->body()]);- $this->handleApiError($finalizeResponse, 'Failed to finalize LinkedIn video upload');+ $this->handleApiError($finalizeResponse);}Log::info('LinkedIn video upload finalized', ['videoUrn' => $videoUrn]);@@ -464,7 +464,7 @@ class LinkedInPublisher]);if ($response->failed()) {- $this->handleApiError($response, 'Failed to refresh LinkedIn token');+ $this->handleApiError($response);}$data = $response->json();@@ -479,7 +479,7 @@ class LinkedInPublisherapp(LinkedInTokenSynchronizer::class)->syncTokens($account);}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw LinkedInPublishException::fromApiResponse($response);}diff --git a/app/Services/Social/PinterestPublisher.php b/app/Services/Social/PinterestPublisher.phpindex 1f7734f86..27468ff4d 100644--- a/app/Services/Social/PinterestPublisher.php+++ b/app/Services/Social/PinterestPublisher.php@@ -108,7 +108,7 @@ class PinterestPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Pinterest API error');+ $this->handleApiError($response);}$data = $response->json();@@ -152,7 +152,7 @@ class PinterestPublisher'status' => $registerResponse->status(),'body' => $registerResponse->body(),]);- $this->handleApiError($registerResponse, 'Pinterest media registration error');+ $this->handleApiError($registerResponse);}$registerData = $registerResponse->json();@@ -246,7 +246,7 @@ class PinterestPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Pinterest API error');+ $this->handleApiError($response);}$data = $response->json();@@ -312,7 +312,7 @@ class PinterestPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Pinterest API error');+ $this->handleApiError($response);}$data = $response->json();@@ -382,7 +382,7 @@ class PinterestPublisherif ($response->failed()) {Log::error('Pinterest token refresh failed', ['body' => $response->body()]);- $this->handleApiError($response, 'Failed to refresh Pinterest token');+ $this->handleApiError($response);}$data = $response->json();@@ -413,13 +413,13 @@ class PinterestPublisherif ($response->failed()) {Log::error('Pinterest get boards failed', ['body' => $response->body()]);- $this->handleApiError($response, 'Pinterest API error');+ $this->handleApiError($response);}return $response->json()['items'] ?? [];}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw PinterestPublishException::fromApiResponse($response);}diff --git a/app/Services/Social/ThreadsPublisher.php b/app/Services/Social/ThreadsPublisher.phpindex 33fad9955..2105c525a 100644--- a/app/Services/Social/ThreadsPublisher.php+++ b/app/Services/Social/ThreadsPublisher.php@@ -68,7 +68,7 @@ class ThreadsPublisher'status' => $containerResponse->status(),'body' => $containerResponse->body(),]);- $this->handleApiError($containerResponse, 'Threads API error');+ $this->handleApiError($containerResponse);}$containerId = $containerResponse->json()['id'];@@ -92,7 +92,7 @@ class ThreadsPublisher'status' => $containerResponse->status(),'body' => $containerResponse->body(),]);- $this->handleApiError($containerResponse, 'Threads API error');+ $this->handleApiError($containerResponse);}$containerId = $containerResponse->json()['id'];@@ -123,7 +123,7 @@ class ThreadsPublisher'status' => $containerResponse->status(),'body' => $containerResponse->body(),]);- $this->handleApiError($containerResponse, 'Threads API error');+ $this->handleApiError($containerResponse);}$containerId = $containerResponse->json()['id'];@@ -195,7 +195,7 @@ class ThreadsPublisherLog::error('Threads carousel container creation failed', ['body' => $carouselResponse->body(),]);- $this->handleApiError($carouselResponse, 'Threads API error');+ $this->handleApiError($carouselResponse);}$carouselId = $carouselResponse->json()['id'];@@ -216,7 +216,7 @@ class ThreadsPublisher'status' => $publishResponse->status(),'body' => $publishResponse->body(),]);- $this->handleApiError($publishResponse, 'Threads publish error');+ $this->handleApiError($publishResponse);}$mediaId = $publishResponse->json()['id'];@@ -292,7 +292,7 @@ class ThreadsPublisherif ($response->failed()) {Log::error('Threads token refresh failed', ['body' => $response->body()]);- $this->handleApiError($response, 'Failed to refresh Threads token');+ $this->handleApiError($response);}$data = $response->json();@@ -308,7 +308,7 @@ class ThreadsPublisherLog::info('Threads token refreshed successfully');}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw ThreadsPublishException::fromApiResponse($response);}diff --git a/app/Services/Social/TikTokPublisher.php b/app/Services/Social/TikTokPublisher.phpindex 2a8835d54..df47c19a2 100644--- a/app/Services/Social/TikTokPublisher.php+++ b/app/Services/Social/TikTokPublisher.php@@ -121,7 +121,7 @@ class TikTokPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'TikTok API error');+ $this->handleApiError($response);}$data = $response->json();@@ -184,7 +184,7 @@ class TikTokPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'TikTok API error');+ $this->handleApiError($response);}$data = $response->json();@@ -277,7 +277,7 @@ class TikTokPublisherif ($response->failed()) {Log::error('TikTok token refresh failed', ['body' => $response->body()]);- $this->handleApiError($response, 'Failed to refresh TikTok token');+ $this->handleApiError($response);}$data = $response->json();@@ -291,7 +291,7 @@ class TikTokPublisherLog::info('TikTok token refreshed successfully');}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw TikTokPublishException::fromApiResponse($response);}diff --git a/app/Services/Social/XPublisher.php b/app/Services/Social/XPublisher.phpindex c4c719039..351a62543 100644--- a/app/Services/Social/XPublisher.php+++ b/app/Services/Social/XPublisher.php@@ -81,7 +81,7 @@ class XPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'X API error');+ $this->handleApiError($response);}$responseData = $response->json();@@ -156,7 +156,7 @@ class XPublisher'status' => $response->status(),'body' => $response->body(),]);- $this->handleApiError($response, 'Failed to upload media');+ $this->handleApiError($response);}$responseData = $response->json();@@ -195,7 +195,7 @@ class XPublisher'status' => $initResponse->status(),'body' => $initResponse->body(),]);- $this->handleApiError($initResponse, 'Failed to initialize chunked upload');+ $this->handleApiError($initResponse);}$initData = $initResponse->json();@@ -238,7 +238,7 @@ class XPublisher'body' => $appendResponse->body(),'segment' => $index,]);- $this->handleApiError($appendResponse, 'Failed to append chunk');+ $this->handleApiError($appendResponse);}$index++;@@ -258,7 +258,7 @@ class XPublisher'status' => $finalizeResponse->status(),'body' => $finalizeResponse->body(),]);- $this->handleApiError($finalizeResponse, 'Failed to finalize chunked upload');+ $this->handleApiError($finalizeResponse);}$finalizeData = $finalizeResponse->json();@@ -348,7 +348,7 @@ class XPublisher]);if ($response->failed()) {- $this->handleApiError($response, 'Failed to refresh X token');+ $this->handleApiError($response);}$data = $response->json();@@ -360,7 +360,7 @@ class XPublisher]);}- private function handleApiError(Response $response, string $context): void+ private function handleApiError(Response $response): never{throw XPublishException::fromApiResponse($response);}