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
fix(social): publish retry honors PlatformUnavailable too
Paulo Castellanoa42962c0cabd
diff --git a/app/Jobs/PublishToSocialPlatform.php b/app/Jobs/PublishToSocialPlatform.phpindex 0ee2b7191..b37c40d1a 100644--- a/app/Jobs/PublishToSocialPlatform.php+++ b/app/Jobs/PublishToSocialPlatform.php@@ -130,6 +130,19 @@ class PublishToSocialPlatform implements ShouldQueue$this->refreshAccountToken();continue;+ } catch (PlatformUnavailableException $refreshError) {+ Log::warning('Publish skipped: platform unavailable during retry refresh', [+ 'post_platform_id' => $this->postPlatform->id,+ 'platform' => $this->postPlatform->platform->value,+ 'error' => $refreshError->getMessage(),+ ]);++ $this->postPlatform->markAsFailed($refreshError->getMessage(), [+ 'category' => 'platform_unavailable',+ 'http_status' => $refreshError->httpStatus,+ 'failed_at' => now()->toIso8601String(),+ ]);+ break;} catch (\Throwable $refreshError) {Log::error('Token refresh failed during publish retry', ['post_platform_id' => $this->postPlatform->id,diff --git a/tests/Feature/Jobs/PublishToSocialPlatformTest.php b/tests/Feature/Jobs/PublishToSocialPlatformTest.phpindex 30d4c1758..ecedf7afb 100644--- a/tests/Feature/Jobs/PublishToSocialPlatformTest.php+++ b/tests/Feature/Jobs/PublishToSocialPlatformTest.php@@ -110,6 +110,36 @@ test('publish to social platform marks account as token expired on auth failure'expect($this->socialAccount->status)->toBe(AccountStatus::TokenExpired);});+test('publish does NOT mark account expired when retry refresh hits platform unavailable', function () {+ Event::fake();+ Mail::fake();++ // Publisher first throws TokenExpired (401-style), the retry-refresh+ // path goes through ConnectionVerifier::verify which can in turn raise+ // PlatformUnavailable if the platform is down. The account must stay+ // Connected — it was the platform that failed, not the token.+ $publisher = Mockery::mock(LinkedInPublisher::class);+ $publisher->shouldReceive('publish')->andThrow(new TokenExpiredException('Token expired', '401'));++ $verifier = Mockery::mock(ConnectionVerifier::class);+ $verifier->shouldReceive('verify')->andThrow(+ new PlatformUnavailableException('LinkedIn API returned 503 during token refresh', 503)+ );++ $this->app->instance(LinkedInPublisher::class, $publisher);+ $this->app->instance(ConnectionVerifier::class, $verifier);++ (new PublishToSocialPlatform($this->postPlatform))->handle();++ $this->postPlatform->refresh();+ $this->socialAccount->refresh();++ expect($this->postPlatform->status)->toBe(PlatformStatus::Failed);+ expect($this->postPlatform->error_context['category'] ?? null)->toBe('platform_unavailable');+ expect($this->postPlatform->error_context['http_status'] ?? null)->toBe(503);+ expect($this->socialAccount->status)->toBe(AccountStatus::Connected);+});+test('publish to social platform does NOT mark account expired when platform is unavailable', function () {Event::fake();Mail::fake();