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.

Leave created_via null when omitted or invalid.

Paulo Castellano588891767bf0
diff --git a/app/Actions/Post/CreatePost.php b/app/Actions/Post/CreatePost.php
index 85adfb066..f4089db5c 100644
--- a/app/Actions/Post/CreatePost.php
+++ b/app/Actions/Post/CreatePost.php
@@ -28,15 +28,15 @@ 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 — defaults to web when omitted
- * or invalid, and never blocks creation.
+ * api, or automation). Analytical only — null when omitted or invalid,
+ * and never blocks creation.
*
* @param array{
* content?: ?string,
* media?: array<int, mixed>,
* date?: ?string,
* scheduled_at?: ?string,
- * created_via?: CreatedVia,
+ * created_via?: ?CreatedVia,
* platforms?: array<int, array{social_account_id: string, content_type?: string, meta?: array<string, mixed>}>,
* label_ids?: array<int, string>
* } $data
@@ -102,7 +102,7 @@ class CreatePost
*
* @param array<string, mixed> $data
*/
- private static function resolveCreatedVia(array $data): CreatedVia
+ private static function resolveCreatedVia(array $data): ?CreatedVia
{
$value = data_get($data, 'created_via');
@@ -111,10 +111,10 @@ class CreatePost
}
if (is_string($value)) {
- return CreatedVia::tryFrom($value) ?? CreatedVia::Web;
+ return CreatedVia::tryFrom($value);
}
- return CreatedVia::Web;
+ return null;
}
/**
diff --git a/tests/Feature/Actions/Post/CreatePostTest.php b/tests/Feature/Actions/Post/CreatePostTest.php
index 20b684900..c9d7ae648 100644
--- a/tests/Feature/Actions/Post/CreatePostTest.php
+++ b/tests/Feature/Actions/Post/CreatePostTest.php
@@ -44,7 +44,7 @@ test('execute persists created_via for each entry point', function (CreatedVia $
'automation' => CreatedVia::Automation,
]);
-test('execute defaults created_via to web when omitted', function () {
+test('execute leaves created_via null when omitted', function () {
$user = User::factory()->create();
$workspace = Workspace::factory()->create(['user_id' => $user->id]);
@@ -52,10 +52,10 @@ test('execute defaults created_via to web when omitted', function () {
'content' => 'Hello world',
]);
- expect($post->fresh()->created_via)->toBe(CreatedVia::Web);
+ expect($post->fresh()->created_via)->toBeNull();
});
-test('execute defaults created_via to web when null or invalid', function (mixed $createdVia) {
+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]);
@@ -64,7 +64,7 @@ test('execute defaults created_via to web when null or invalid', function (mixed
'created_via' => $createdVia,
]);
- expect($post->fresh()->created_via)->toBe(CreatedVia::Web);
+ expect($post->fresh()->created_via)->toBeNull();
})->with([
'null' => null,
'invalid string' => 'not-a-channel',