- 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
36 lines
1,010 B
PHP
36 lines
1,010 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Enums\SocialAccount\Status;
|
|
use App\Jobs\RefreshSocialToken;
|
|
use App\Models\SocialAccount;
|
|
use Illuminate\Console\Command;
|
|
|
|
class RefreshExpiringTokens extends Command
|
|
{
|
|
protected $signature = 'social:refresh-expiring-tokens';
|
|
|
|
protected $description = 'Proactively refresh tokens expiring in the next 2 hours';
|
|
|
|
public function handle(): void
|
|
{
|
|
$count = 0;
|
|
|
|
SocialAccount::query()
|
|
->where('status', Status::Connected)
|
|
->whereNotNull('token_expires_at')
|
|
->where('token_expires_at', '<=', now()->addHours(2))
|
|
->where('token_expires_at', '>', now())
|
|
->chunk(50, function ($accounts) use (&$count) {
|
|
foreach ($accounts as $account) {
|
|
RefreshSocialToken::dispatch($account);
|
|
$count++;
|
|
}
|
|
});
|
|
|
|
$this->info("Dispatched {$count} token refresh jobs.");
|
|
}
|
|
}
|