From 543d83e7eda5ca1a72920a235da2ce40b98871ae Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 5 Dec 2024 23:19:08 -0700 Subject: [PATCH 1/3] Fix newlines --- 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/StatusStatelessTransformer.php | 2 +- app/Transformer/Api/StatusTransformer.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Transformer/ActivityPub/StatusTransformer.php b/app/Transformer/ActivityPub/StatusTransformer.php index c0c378c7b..ec7a71d6e 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 ? Autolink::create()->autolink($status->caption) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; return [ '@context' => [ diff --git a/app/Transformer/ActivityPub/Verb/CreateNote.php b/app/Transformer/ActivityPub/Verb/CreateNote.php index 287393572..1061dadb7 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 ? Autolink::create()->autolink($status->caption) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; return [ '@context' => [ diff --git a/app/Transformer/ActivityPub/Verb/Note.php b/app/Transformer/ActivityPub/Verb/Note.php index 52656efec..0c8e20c03 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 ? Autolink::create()->autolink($status->caption) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; return [ '@context' => [ diff --git a/app/Transformer/ActivityPub/Verb/UpdateNote.php b/app/Transformer/ActivityPub/Verb/UpdateNote.php index 09d0b5a2b..07f0c7e11 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 ? Autolink::create()->autolink($status->caption) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; $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 4516bd874..202b82d54 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 ? Autolink::create()->autolink($status->caption) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; return [ 'id' => (string) $status->id, diff --git a/app/Transformer/Api/StatusStatelessTransformer.php b/app/Transformer/Api/StatusStatelessTransformer.php index bf6e7597e..db454fc9b 100644 --- a/app/Transformer/Api/StatusStatelessTransformer.php +++ b/app/Transformer/Api/StatusStatelessTransformer.php @@ -23,7 +23,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract { $taggedPeople = MediaTagService::get($status->id); $poll = $status->type === 'poll' ? PollService::get($status->id) : null; - $rendered = $status->caption ? Autolink::create()->autolink($status->caption) : null; + $rendered = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; return [ '_v' => 1, diff --git a/app/Transformer/Api/StatusTransformer.php b/app/Transformer/Api/StatusTransformer.php index 6f9364194..a4abfad68 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 ? Autolink::create()->autolink($status->caption) : null; + $content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : null; return [ '_v' => 1, From 56c07b7abd3bbbd6eac8343c15c241bc3324f057 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 5 Dec 2024 23:20:19 -0700 Subject: [PATCH 2/3] Update StatusService.php --- app/Services/StatusService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/StatusService.php b/app/Services/StatusService.php index 621574f09..64a434d32 100644 --- a/app/Services/StatusService.php +++ b/app/Services/StatusService.php @@ -10,7 +10,7 @@ use League\Fractal\Serializer\ArraySerializer; class StatusService { - const CACHE_KEY = 'pf:services:status:'; + const CACHE_KEY = 'pf:services:status:v1:'; public static function key($id, $publicOnly = true) { From b21cdc07a0d038f10324090d69dcdc286ee8466a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 5 Dec 2024 23:23:46 -0700 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1730d85fd..510e7e813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ - Update ApiV1Controller, fix bookmark bug. Closes #5216 ([9f7cc52c](https://github.com/pixelfed/pixelfed/commit/9f7cc52c)) - Update Status caption logic, stop storing duplicate html caption in db and defer to cached StatusService rendering ([9eeb7b67](https://github.com/pixelfed/pixelfed/commit/9eeb7b67)) - Update AutolinkService, optimize lookups ([eac2c196](https://github.com/pixelfed/pixelfed/commit/eac2c196)) +- Update DirectMessageController, remove 72h limit for admins ([639df410](https://github.com/pixelfed/pixelfed/commit/639df410)) +- Update StatusService, fix newlines ([56c07b7a](https://github.com/pixelfed/pixelfed/commit/56c07b7a)) +- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.12.4 (2024-11-08)](https://github.com/pixelfed/pixelfed/compare/v0.12.4...dev)