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.

Bring post platform meta (aspect ratio) to parity across API and MCP

Paulo Castellanoce6ee0488341
diff --git a/app/Actions/Post/CreatePost.php b/app/Actions/Post/CreatePost.php
index bfdb75bdb..008ace8a7 100644
--- a/app/Actions/Post/CreatePost.php
+++ b/app/Actions/Post/CreatePost.php
@@ -62,6 +62,10 @@ class CreatePost
$updates['content_type'] = $contentType;
}
+ if (($meta = data_get($platformData, 'meta')) !== null) {
+ $updates['meta'] = $meta;
+ }
+
$post->postPlatforms()
->where('social_account_id', $accountId)
->update($updates);
diff --git a/app/Enums/PostPlatform/AspectRatio.php b/app/Enums/PostPlatform/AspectRatio.php
new file mode 100644
index 000000000..52365b4c5
--- /dev/null
+++ b/app/Enums/PostPlatform/AspectRatio.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Enums\PostPlatform;
+
+enum AspectRatio: string
+{
+ case Square = '1:1';
+ case Portrait = '4:5';
+ case Landscape = '16:9';
+ case Original = 'original';
+}
diff --git a/app/Http/Requests/Api/Post/StorePostRequest.php b/app/Http/Requests/Api/Post/StorePostRequest.php
index 309f1ed9e..979a448cd 100644
--- a/app/Http/Requests/Api/Post/StorePostRequest.php
+++ b/app/Http/Requests/Api/Post/StorePostRequest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Requests\Api\Post;
+use App\Enums\PostPlatform\AspectRatio;
use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
use App\Models\SocialAccount;
@@ -49,6 +50,8 @@ class StorePostRequest extends FormRequest
Rule::in(array_column(ContentType::cases(), 'value')),
new ContentTypeMatchesPlatform,
],
+ 'platforms.*.meta' => ['sometimes', 'nullable', 'array'],
+ 'platforms.*.meta.aspect_ratio' => ['sometimes', 'nullable', 'string', Rule::enum(AspectRatio::class)],
'scheduled_at' => ['nullable', 'date', 'after:now'],
'label_ids' => ['sometimes', 'array'],
'label_ids.*' => [
diff --git a/app/Http/Requests/Api/Post/UpdatePostRequest.php b/app/Http/Requests/Api/Post/UpdatePostRequest.php
index 953157816..939e4a5dc 100644
--- a/app/Http/Requests/Api/Post/UpdatePostRequest.php
+++ b/app/Http/Requests/Api/Post/UpdatePostRequest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Http\Requests\Api\Post;
use App\Enums\Post\Status;
+use App\Enums\PostPlatform\AspectRatio;
use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
use App\Models\Post;
@@ -51,6 +52,7 @@ class UpdatePostRequest extends FormRequest
new ContentTypeMatchesPostPlatform,
],
'platforms.*.meta' => ['nullable', 'array'],
+ 'platforms.*.meta.aspect_ratio' => ['sometimes', 'nullable', 'string', Rule::enum(AspectRatio::class)],
'scheduled_at' => [
'nullable',
'date',
diff --git a/app/Http/Requests/App/Post/UpdatePostRequest.php b/app/Http/Requests/App/Post/UpdatePostRequest.php
index eaa2d2afb..479410858 100644
--- a/app/Http/Requests/App/Post/UpdatePostRequest.php
+++ b/app/Http/Requests/App/Post/UpdatePostRequest.php
@@ -6,6 +6,7 @@ namespace App\Http\Requests\App\Post;
use App\Enums\Media\Source;
use App\Enums\Post\Status;
+use App\Enums\PostPlatform\AspectRatio;
use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
use App\Rules\ContentFitsPlatformLimits;
@@ -70,7 +71,7 @@ class UpdatePostRequest extends FormRequest
Rule::when($enforcesMediaCompatibility, [new ContentTypeCompatibleWithMedia]),
],
'platforms.*.meta' => ['nullable', 'array'],
- 'platforms.*.meta.aspect_ratio' => ['sometimes', 'nullable', 'string', Rule::in(['1:1', '4:5', '16:9', 'original'])],
+ 'platforms.*.meta.aspect_ratio' => ['sometimes', 'nullable', 'string', Rule::enum(AspectRatio::class)],
'platforms.*.meta.privacy_level' => ['sometimes', 'nullable', 'string', Rule::in(['PUBLIC_TO_EVERYONE', 'MUTUAL_FOLLOW_FRIENDS', 'FOLLOWER_OF_CREATOR', 'SELF_ONLY'])],
'platforms.*.meta.auto_add_music' => ['sometimes', 'boolean'],
'platforms.*.meta.allow_comments' => ['sometimes', 'boolean'],
diff --git a/app/Http/Resources/Api/PostPlatformResource.php b/app/Http/Resources/Api/PostPlatformResource.php
index 147179e90..3995c87c6 100644
--- a/app/Http/Resources/Api/PostPlatformResource.php
+++ b/app/Http/Resources/Api/PostPlatformResource.php
@@ -18,6 +18,7 @@ class PostPlatformResource extends JsonResource
'id' => $this->id,
'platform' => $this->platform?->value,
'content_type' => $this->content_type?->value,
+ 'meta' => $this->meta,
'status' => $this->status?->value,
'enabled' => $this->enabled,
'platform_url' => $this->platform_url,
diff --git a/app/Mcp/Tools/Post/CreatePostTool.php b/app/Mcp/Tools/Post/CreatePostTool.php
index 1709dbc51..35437834b 100644
--- a/app/Mcp/Tools/Post/CreatePostTool.php
+++ b/app/Mcp/Tools/Post/CreatePostTool.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Mcp\Tools\Post;
use App\Actions\Post\CreatePost;
+use App\Enums\PostPlatform\AspectRatio;
use App\Enums\PostPlatform\ContentType;
use App\Http\Resources\Api\PostResource;
use App\Rules\ContentTypeMatchesPlatform;
@@ -37,6 +38,8 @@ class CreatePostTool extends Tool
->where('is_active', true),
],
'platforms.*.content_type' => ['required', 'string', Rule::in(array_column(ContentType::cases(), 'value')), new ContentTypeMatchesPlatform],
+ 'platforms.*.meta' => ['sometimes', 'array'],
+ 'platforms.*.meta.aspect_ratio' => ['sometimes', 'nullable', 'string', Rule::enum(AspectRatio::class)],
]);
$post = CreatePost::execute($workspace, $request->user(), $validated);
@@ -58,6 +61,7 @@ class CreatePostTool extends Tool
->items($schema->object(fn ($p) => [
'social_account_id' => $p->string()->required()->description('UUID of the connected social account.'),
'content_type' => $p->string()->required()->description('Format for this platform (e.g. linkedin_post, x_post, instagram_feed).'),
+ 'meta' => $p->object()->description('Per-platform metadata (e.g. aspect_ratio: 1:1|4:5|16:9|original for Instagram/Facebook feed images).'),
]))
->description('Platforms to publish on. Accounts not listed remain available but disabled.'),
];
diff --git a/app/Mcp/Tools/Post/UpdatePostTool.php b/app/Mcp/Tools/Post/UpdatePostTool.php
index 564e633fc..c3e26aae6 100644
--- a/app/Mcp/Tools/Post/UpdatePostTool.php
+++ b/app/Mcp/Tools/Post/UpdatePostTool.php
@@ -7,6 +7,7 @@ namespace App\Mcp\Tools\Post;
use App\Actions\Post\UpdatePost;
use App\Enums\Post\Action as PostAction;
use App\Enums\Post\Status;
+use App\Enums\PostPlatform\AspectRatio;
use App\Enums\PostPlatform\ContentType;
use App\Http\Resources\Api\PostResource;
use App\Models\Post;
@@ -49,6 +50,7 @@ class UpdatePostTool extends Tool
],
'platforms.*.content_type' => ['sometimes', 'string', Rule::in(array_column(ContentType::cases(), 'value')), new ContentTypeMatchesPostPlatform],
'platforms.*.meta' => ['sometimes', 'array'],
+ 'platforms.*.meta.aspect_ratio' => ['sometimes', 'nullable', 'string', Rule::enum(AspectRatio::class)],
]);
$payload = collect($validated)->except('post_id')->all();
diff --git a/tests/Feature/Api/PostApiTest.php b/tests/Feature/Api/PostApiTest.php
index 5c6018a86..eee56afda 100644
--- a/tests/Feature/Api/PostApiTest.php
+++ b/tests/Feature/Api/PostApiTest.php
@@ -577,3 +577,50 @@ it('show post returns correct structure', function () {
->assertOk()
->assertJsonStructure(['id', 'status', 'scheduled_at', 'published_at']);
});
+
+it('creates a post with platform meta (aspect_ratio) and returns it', function () {
+ $this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken])
+ ->postJson(route('api.posts.store'), [
+ 'platforms' => [
+ ['social_account_id' => $this->socialAccount->id, 'content_type' => 'linkedin_post', 'meta' => ['aspect_ratio' => '4:5']],
+ ],
+ ])
+ ->assertCreated()
+ ->assertJsonPath('platforms.0.meta.aspect_ratio', '4:5');
+
+ $platform = Post::where('workspace_id', $this->workspace->id)->first()
+ ->postPlatforms()->where('social_account_id', $this->socialAccount->id)->first();
+ expect($platform->meta['aspect_ratio'])->toBe('4:5');
+});
+
+it('rejects creating a post with an invalid aspect_ratio', function () {
+ $this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken])
+ ->postJson(route('api.posts.store'), [
+ 'platforms' => [
+ ['social_account_id' => $this->socialAccount->id, 'content_type' => 'linkedin_post', 'meta' => ['aspect_ratio' => '3:2']],
+ ],
+ ])
+ ->assertJsonValidationErrors(['platforms.0.meta.aspect_ratio']);
+});
+
+it('rejects updating a post with an invalid aspect_ratio', function () {
+ $post = Post::factory()->create([
+ 'workspace_id' => $this->workspace->id,
+ 'user_id' => $this->user->id,
+ 'status' => PostStatus::Draft,
+ ]);
+ $postPlatform = PostPlatform::factory()->linkedin()->create([
+ 'post_id' => $post->id,
+ 'social_account_id' => $this->socialAccount->id,
+ 'enabled' => true,
+ ]);
+
+ $this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken])
+ ->putJson(route('api.posts.update', $post), [
+ 'status' => 'draft',
+ 'platforms' => [
+ ['id' => $postPlatform->id, 'content_type' => 'linkedin_post', 'meta' => ['aspect_ratio' => '3:2']],
+ ],
+ ])
+ ->assertJsonValidationErrors(['platforms.0.meta.aspect_ratio']);
+});
diff --git a/tests/Feature/Mcp/PostToolTest.php b/tests/Feature/Mcp/PostToolTest.php
index f06b46d7a..c234460df 100644
--- a/tests/Feature/Mcp/PostToolTest.php
+++ b/tests/Feature/Mcp/PostToolTest.php
@@ -276,3 +276,50 @@ test('delete post validates post_id required', function () {
$response->assertHasErrors();
});
+
+test('create post persists platform meta (aspect_ratio)', function () {
+ $response = TryPostServer::actingAs($this->user)
+ ->tool(CreatePostTool::class, [
+ 'platforms' => [
+ ['social_account_id' => $this->socialAccount->id, 'content_type' => 'linkedin_post', 'meta' => ['aspect_ratio' => '4:5']],
+ ],
+ ]);
+
+ $response->assertOk();
+
+ $platform = Post::where('workspace_id', $this->workspace->id)->first()
+ ->postPlatforms()->where('social_account_id', $this->socialAccount->id)->first();
+ expect($platform->meta['aspect_ratio'])->toBe('4:5');
+});
+
+test('create post rejects an invalid aspect_ratio', function () {
+ $response = TryPostServer::actingAs($this->user)
+ ->tool(CreatePostTool::class, [
+ 'platforms' => [
+ ['social_account_id' => $this->socialAccount->id, 'content_type' => 'linkedin_post', 'meta' => ['aspect_ratio' => '3:2']],
+ ],
+ ]);
+
+ $response->assertHasErrors();
+});
+
+test('update post rejects an invalid aspect_ratio', function () {
+ $post = Post::factory()->create([
+ 'workspace_id' => $this->workspace->id,
+ 'user_id' => $this->user->id,
+ ]);
+ $platform = PostPlatform::factory()->create([
+ 'post_id' => $post->id,
+ 'social_account_id' => $this->socialAccount->id,
+ ]);
+
+ $response = TryPostServer::actingAs($this->user)
+ ->tool(UpdatePostTool::class, [
+ 'post_id' => $post->id,
+ 'platforms' => [
+ ['id' => $platform->id, 'meta' => ['aspect_ratio' => '3:2']],
+ ],
+ ]);
+
+ $response->assertHasErrors();
+});