Skip to content

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.

872 B
Raw Blame
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Enums\SocialAccount\Status;
use App\Jobs\VerifyWorkspaceConnections;
use App\Models\Workspace;
use Illuminate\Console\Command;

class CheckSocialConnections extends Command
{
    protected $signature = 'social:check-connections';

    protected $description = 'Verify that all connected social accounts have valid tokens';

    public function handle(): void
    {
        Workspace::query()
            ->whereHas('socialAccounts', function ($query) {
                $query->whereIn('status', [Status::Connected, Status::TokenExpired]);
            })
            ->with('owner')
            ->chunk(100, function ($workspaces) {
                foreach ($workspaces as $workspace) {
                    VerifyWorkspaceConnections::dispatch($workspace);
                }
            });
    }
}