Respect Micropub post-status when creating articles
Articles created via Micropub were always published immediately, ignoring the client-supplied post-status property. Clients like iA Writer that publish drafts (post-status: draft) had no way to land an article as unpublished. EntryData now extracts post-status from the request, and ArticleService sets published accordingly, defaulting to true when the property is omitted or set to anything other than "draft". Fixes #123 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXyzNvQZPQgBoSZwW7cLG8
This commit is contained in:
parent
99f306ede1
commit
a76c84b40f
3 changed files with 37 additions and 1 deletions
|
|
@ -869,6 +869,37 @@ class MicropubControllerTest extends TestCase
|
|||
$this->assertDatabaseHas('articles', [
|
||||
'title' => $name,
|
||||
'main' => $content,
|
||||
'published' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function micropub_client_api_request_creates_an_unpublished_article_when_post_status_is_draft(): void
|
||||
{
|
||||
$faker = Factory::create();
|
||||
$name = $faker->text(50);
|
||||
$content = $faker->paragraphs(5, true);
|
||||
|
||||
$response = $this->postJson(
|
||||
'/api/post',
|
||||
[
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'name' => [$name],
|
||||
'content' => [$content],
|
||||
'post-status' => ['draft'],
|
||||
],
|
||||
],
|
||||
['HTTP_Authorization' => 'Bearer '.$this->getToken()]
|
||||
);
|
||||
|
||||
$response
|
||||
->assertJson(['response' => 'created'])
|
||||
->assertStatus(201);
|
||||
$this->assertDatabaseHas('articles', [
|
||||
'title' => $name,
|
||||
'main' => $content,
|
||||
'published' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue