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.

874 B
Raw Blame
<?php

declare(strict_types=1);

namespace App\Support\Social;

use App\Models\Post;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Throwable;

class GoogleBusinessDerivativeCleaner
{
    public const string DIRECTORY = 'google-business-derivatives';

    /**
     * The JPEG is named after the post.
     */
    public static function pathFor(Post $post): string
    {
        return self::DIRECTORY."/{$post->id}.jpg";
    }

    public function cleanup(Post $post): void
    {
        $path = self::pathFor($post);

        try {
            Storage::delete($path);
        } catch (Throwable $e) {
            Log::warning('Failed to prune Google Business Profile image derivative', [
                'post_id' => $post->id,
                'path' => $path,
                'error' => $e->getMessage(),
            ]);
        }
    }
}