MTM Fix UpdateHandler error from OwnYourSwarm checkin #84

Merged
jonny merged 1 commit from develop into main 2026-03-18 18:46:38 +01:00
2 changed files with 24 additions and 1 deletions

View file

@ -53,7 +53,7 @@ class UpdateHandler implements MicropubHandlerInterface
if ($data->updateReplace !== null) { if ($data->updateReplace !== null) {
foreach ($data->updateReplace as $property => $value) { foreach ($data->updateReplace as $property => $value) {
match ($property) { match ($property) {
'content' => $note->note = $value[0], 'content' => $note->note = is_array($value[0]) ? ($value[0]['html'] ?? $value[0]['value'] ?? null) : $value[0],
'syndication' => $this->applySyndication($note, $value), 'syndication' => $this->applySyndication($note, $value),
default => null, default => null,
}; };

View file

@ -538,6 +538,29 @@ class MicropubControllerTest extends TestCase
$this->assertSame('replaced content', $note->content); $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] #[Test]
public function micropub_client_api_request_updates_note_syndication_links(): void public function micropub_client_api_request_updates_note_syndication_links(): void
{ {