- Add HasSocialHttpClient trait with 429 rate limit retry (3 attempts, 5s delay) - Integrate trait into all 10 publishers (YouTube uses Google SDK) - Add inline token refresh retry in PublishToSocialPlatform job - Add per-platform Horizon queues via Platform::queue() and Platform::allQueues() - Add RefreshExpiringTokens hourly command for proactive token refresh - Fix token leaks: redact response bodies in all Log::error calls - Fix token leaks: remove $response->body() from exception messages - Fix ConnectionVerifier: redact all refresh error logs - Fix null checks on API response IDs (Instagram, Threads, Pinterest, Facebook) - Fix PublishPost::failed() to mark post as failed - Fix StoreChunkedMediaRequest: validate max 1GB total size - Fix scheduled_at validation: string → date - Fix StoreMediaRequest: images max 10MB, videos max 1GB, only MP4 video
40 lines
1,011 B
PHP
40 lines
1,011 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Social\Concerns;
|
|
|
|
use Illuminate\Http\Client\PendingRequest;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
trait HasSocialHttpClient
|
|
{
|
|
protected function socialHttp(): PendingRequest
|
|
{
|
|
return Http::retry(
|
|
times: 3,
|
|
sleepMilliseconds: 5000,
|
|
when: fn ($exception, $request) => $exception->response?->status() === 429,
|
|
throw: false,
|
|
)->timeout(120);
|
|
}
|
|
|
|
protected function redactResponseBody(string $body): string
|
|
{
|
|
return preg_replace(
|
|
[
|
|
'/access_token=([^&"\s]+)/',
|
|
'/"access_token"\s*:\s*"([^"]+)"/',
|
|
'/Bearer\s+\S+/',
|
|
'/"token"\s*:\s*"([^"]+)"/',
|
|
],
|
|
[
|
|
'access_token=[REDACTED]',
|
|
'"access_token":"[REDACTED]"',
|
|
'Bearer [REDACTED]',
|
|
'"token":"[REDACTED]"',
|
|
],
|
|
$body
|
|
);
|
|
}
|
|
}
|