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.

fix(automations): persist the Generate node content style

Paulo Castellano31de750c7158
diff --git a/app/Http/Requests/App/Automations/UpdateAutomationRequest.php b/app/Http/Requests/App/Automations/UpdateAutomationRequest.php
index 0b0a36770..f89de16fc 100644
--- a/app/Http/Requests/App/Automations/UpdateAutomationRequest.php
+++ b/app/Http/Requests/App/Automations/UpdateAutomationRequest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Requests\App\Automations;
+use App\Enums\Ai\ContentStyle;
use App\Enums\Automation\AuthType;
use App\Enums\Automation\Condition\Operator as ConditionOperator;
use App\Enums\Automation\DelayUnit;
@@ -156,6 +157,7 @@ class UpdateAutomationRequest extends FormRequest
'target_slide_count' => ['nullable', 'integer', 'min:0', 'max:'.GenerateNodeValidator::MAX_GENERATED_IMAGES],
'use_brand_voice' => ['sometimes', 'boolean'],
'use_brand_visuals' => ['sometimes', 'boolean'],
+ 'style' => ['sometimes', Rule::in(array_column(ContentStyle::cases(), 'value'))],
],
NodeType::Delay->value => [
'duration' => ['required', 'integer', 'min:1'],
diff --git a/tests/Feature/Automation/AutomationCrudTest.php b/tests/Feature/Automation/AutomationCrudTest.php
index b362778d3..fa73c5b19 100644
--- a/tests/Feature/Automation/AutomationCrudTest.php
+++ b/tests/Feature/Automation/AutomationCrudTest.php
@@ -60,6 +60,49 @@ it('updates nodes and connections via PUT', function () {
expect($automation->fresh()->nodes)->toHaveCount(3);
});
+it('persists the generate node style through a save round-trip', function () {
+ $automation = Automation::factory()->for($this->workspace)->create();
+
+ $payload = [
+ 'nodes' => [
+ ['id' => 'n1', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => ['trigger_type' => 'schedule', 'cron' => '0 9 * * *']],
+ ['id' => 'n2', 'type' => 'generate', 'position' => ['x' => 200, 'y' => 0], 'data' => [
+ 'accounts' => [['social_account_id' => 'acc-1']],
+ 'prompt_template' => 'hi',
+ 'style' => 'tweet_card',
+ ]],
+ ],
+ 'connections' => [['id' => 'e1', 'source' => 'n1', 'target' => 'n2']],
+ ];
+
+ $this->actingAs($this->user)
+ ->put(route('app.automations.update', $automation->id), $payload)
+ ->assertRedirect();
+
+ $node = collect($automation->fresh()->nodes)->firstWhere('type', 'generate');
+ expect($node['data']['style'])->toBe('tweet_card');
+});
+
+it('rejects an unknown generate node style', function () {
+ $automation = Automation::factory()->for($this->workspace)->create();
+
+ $payload = [
+ 'nodes' => [
+ ['id' => 'n1', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => ['trigger_type' => 'schedule', 'cron' => '0 9 * * *']],
+ ['id' => 'n2', 'type' => 'generate', 'position' => ['x' => 200, 'y' => 0], 'data' => [
+ 'accounts' => [['social_account_id' => 'acc-1']],
+ 'prompt_template' => 'hi',
+ 'style' => 'not_a_real_style',
+ ]],
+ ],
+ 'connections' => [['id' => 'e1', 'source' => 'n1', 'target' => 'n2']],
+ ];
+
+ $this->actingAs($this->user)
+ ->put(route('app.automations.update', $automation->id), $payload)
+ ->assertSessionHasErrors('nodes.1.data.style');
+});
+
it('persists every trigger schedule editor field through a save round-trip', function (array $scheduleData) {
$automation = Automation::factory()->for($this->workspace)->create();