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.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Simplify created_via persistence to a plain data_get.
Paulo Castellano227ee45c2bb2
diff --git a/app/Actions/Post/CreatePost.php b/app/Actions/Post/CreatePost.phpindex f4089db5c..11c5a1f43 100644--- a/app/Actions/Post/CreatePost.php+++ b/app/Actions/Post/CreatePost.php@@ -28,8 +28,7 @@ class CreatePost* works for REST, MCP, and web callers.** `created_via` records which entry point created the post (web, mcp,- * api, or automation). Analytical only — null when omitted or invalid,- * and never blocks creation.+ * api, or automation). Analytical only — null when omitted.** @param array{* content?: ?string,@@ -51,7 +50,7 @@ class CreatePost'content' => data_get($data, 'content', ''),'media' => data_get($data, 'media', []),'status' => PostStatus::Draft,- 'created_via' => self::resolveCreatedVia($data),+ 'created_via' => data_get($data, 'created_via'),'scheduled_at' => $scheduledAt,]);@@ -97,26 +96,6 @@ class CreatePostreturn $post;}- /**- * Analytical only — never fail creation over a missing/invalid value.- *- * @param array<string, mixed> $data- */- private static function resolveCreatedVia(array $data): ?CreatedVia- {- $value = data_get($data, 'created_via');-- if ($value instanceof CreatedVia) {- return $value;- }-- if (is_string($value)) {- return CreatedVia::tryFrom($value);- }-- return null;- }-/*** @param array<string, mixed> $data*/diff --git a/tests/Feature/Actions/Post/CreatePostTest.php b/tests/Feature/Actions/Post/CreatePostTest.phpindex c9d7ae648..410257dd9 100644--- a/tests/Feature/Actions/Post/CreatePostTest.php+++ b/tests/Feature/Actions/Post/CreatePostTest.php@@ -54,19 +54,3 @@ test('execute leaves created_via null when omitted', function () {expect($post->fresh()->created_via)->toBeNull();});--test('execute leaves created_via null when null or invalid', function (mixed $createdVia) {- $user = User::factory()->create();- $workspace = Workspace::factory()->create(['user_id' => $user->id]);-- $post = CreatePost::execute($workspace, $user, [- 'content' => 'Hello world',- 'created_via' => $createdVia,- ]);-- expect($post->fresh()->created_via)->toBeNull();-})->with([- 'null' => null,- 'invalid string' => 'not-a-channel',- 'integer' => 1,-]);