Fix UpdateHandler crash when replace.content is a rich-text object

OwnYourSwarm sends content as an array of objects with `value` and `html`
keys per the Micropub spec. The handler now handles both forms: plain
strings and rich objects, preferring `html` over `value`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jonny Barnes 2026-03-18 17:43:57 +00:00
commit e8e2bff5e4
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
2 changed files with 24 additions and 1 deletions

View file

@ -538,6 +538,29 @@ class MicropubControllerTest extends TestCase
$this->assertSame('replaced content', $note->content);
}
#[Test]
public function micropub_client_api_request_updates_existing_note_with_rich_text_content(): void
{
$note = Note::factory()->create();
$response = $this->postJson(
'/api/post',
[
'action' => 'update',
'url' => $note->uri,
'replace' => [
'content' => [['value' => 'plain text', 'html' => 'html version']],
],
],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
$response
->assertJson(['response' => 'updated'])
->assertSuccessful();
$note->refresh();
$this->assertSame('html version', $note->content);
}
#[Test]
public function micropub_client_api_request_updates_note_syndication_links(): void
{