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: update scheduled_at to current time when publishing immediately

Paulo Castellano0cd5e8f74423
diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php
index 7cb80ccf9..c8b14c640 100644
--- a/app/Http/Controllers/PostController.php
+++ b/app/Http/Controllers/PostController.php
@@ -262,6 +262,7 @@ class PostController extends Controller
// Dispatch publish job if publishing now
if ($status === 'publishing') {
+ $post->update(['scheduled_at' => now()]);
PublishPost::dispatch($post);
session()->flash('flash.banner', __('posts.flash.publishing'));
diff --git a/tests/Feature/PostControllerTest.php b/tests/Feature/PostControllerTest.php
index ab6bc6772..1bd904112 100644
--- a/tests/Feature/PostControllerTest.php
+++ b/tests/Feature/PostControllerTest.php
@@ -230,6 +230,39 @@ test('update post cannot update published posts', function () {
$response->assertRedirect();
});
+test('publish now updates scheduled_at to current time', function () {
+ $this->freezeTime();
+
+ $post = Post::factory()->create([
+ 'workspace_id' => $this->workspace->id,
+ 'user_id' => $this->user->id,
+ 'status' => PostStatus::Draft,
+ 'scheduled_at' => now()->addDays(7),
+ ]);
+
+ $postPlatform = PostPlatform::factory()->create([
+ 'post_id' => $post->id,
+ 'social_account_id' => $this->socialAccount->id,
+ 'content' => 'Test content',
+ ]);
+
+ $response = $this->actingAs($this->user)->put(route('posts.update', $post), [
+ 'status' => 'publishing',
+ 'platforms' => [
+ [
+ 'id' => $postPlatform->id,
+ 'content' => 'Test content',
+ 'content_type' => ContentType::LinkedInPost->value,
+ ],
+ ],
+ ]);
+
+ $response->assertRedirect();
+
+ $post->refresh();
+ expect($post->scheduled_at->toDateTimeString())->toBe(now()->toDateTimeString());
+});
+
// Destroy tests
test('destroy post requires authentication', function () {
$post = Post::factory()->create([