From 1f30beccf3d2323f25272ea082bd591ab5b0da27 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 6 Dec 2024 03:23:55 -0700 Subject: [PATCH] Update Transformers to comply with MastoAPI --- app/Transformer/ActivityPub/StatusTransformer.php | 2 +- app/Transformer/ActivityPub/Verb/CreateNote.php | 2 +- app/Transformer/ActivityPub/Verb/Note.php | 2 +- app/Transformer/ActivityPub/Verb/UpdateNote.php | 2 +- app/Transformer/Api/Mastodon/v1/StatusTransformer.php | 2 +- app/Transformer/Api/StatusTransformer.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Transformer/ActivityPub/StatusTransformer.php b/app/Transformer/ActivityPub/StatusTransformer.php index ec7a71d6e..c7f61b88b 100644 --- a/app/Transformer/ActivityPub/StatusTransformer.php +++ b/app/Transformer/ActivityPub/StatusTransformer.php @@ -11,7 +11,7 @@ class StatusTransformer extends Fractal\TransformerAbstract { public function transform(Status $status) { - $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : ""; return [ '@context' => [ diff --git a/app/Transformer/ActivityPub/Verb/CreateNote.php b/app/Transformer/ActivityPub/Verb/CreateNote.php index 1061dadb7..cf2f0fb51 100644 --- a/app/Transformer/ActivityPub/Verb/CreateNote.php +++ b/app/Transformer/ActivityPub/Verb/CreateNote.php @@ -52,7 +52,7 @@ class CreateNote extends Fractal\TransformerAbstract $emojis = CustomEmoji::scan($status->caption, true) ?? []; $emoji = array_merge($emojis, $mentions); $tags = array_merge($emoji, $hashtags); - $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : ""; return [ '@context' => [ diff --git a/app/Transformer/ActivityPub/Verb/Note.php b/app/Transformer/ActivityPub/Verb/Note.php index 0c8e20c03..bc34761cd 100644 --- a/app/Transformer/ActivityPub/Verb/Note.php +++ b/app/Transformer/ActivityPub/Verb/Note.php @@ -53,7 +53,7 @@ class Note extends Fractal\TransformerAbstract $emojis = CustomEmoji::scan($status->caption, true) ?? []; $emoji = array_merge($emojis, $mentions); $tags = array_merge($emoji, $hashtags); - $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : ""; return [ '@context' => [ diff --git a/app/Transformer/ActivityPub/Verb/UpdateNote.php b/app/Transformer/ActivityPub/Verb/UpdateNote.php index 07f0c7e11..4199f7230 100644 --- a/app/Transformer/ActivityPub/Verb/UpdateNote.php +++ b/app/Transformer/ActivityPub/Verb/UpdateNote.php @@ -53,7 +53,7 @@ class UpdateNote extends Fractal\TransformerAbstract $emoji = array_merge($emojis, $mentions); $tags = array_merge($emoji, $hashtags); - $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : ""; $latestEdit = $status->edits()->latest()->first(); return [ diff --git a/app/Transformer/Api/Mastodon/v1/StatusTransformer.php b/app/Transformer/Api/Mastodon/v1/StatusTransformer.php index 202b82d54..16ff4cc30 100644 --- a/app/Transformer/Api/Mastodon/v1/StatusTransformer.php +++ b/app/Transformer/Api/Mastodon/v1/StatusTransformer.php @@ -13,7 +13,7 @@ class StatusTransformer extends Fractal\TransformerAbstract { public function transform(Status $status) { - $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : ""; return [ 'id' => (string) $status->id, diff --git a/app/Transformer/Api/StatusTransformer.php b/app/Transformer/Api/StatusTransformer.php index a4abfad68..4dc08b618 100644 --- a/app/Transformer/Api/StatusTransformer.php +++ b/app/Transformer/Api/StatusTransformer.php @@ -25,7 +25,7 @@ class StatusTransformer extends Fractal\TransformerAbstract $pid = request()->user()->profile_id; $taggedPeople = MediaTagService::get($status->id); $poll = $status->type === 'poll' ? PollService::get($status->id, $pid) : null; - $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : ""; return [ '_v' => 1,