Merge pull request #4702 from pixelfed/staging

Update StatusTransformer, generate autolink on request
This commit is contained in:
daniel 2023-10-16 06:30:16 -06:00 committed by GitHub
commit 7cbdac7adb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -16,6 +16,7 @@ use App\Services\StatusLabelService;
use App\Services\StatusMentionService;
use App\Services\PollService;
use App\Models\CustomEmoji;
use App\Util\Lexer\Autolink;
class StatusStatelessTransformer extends Fractal\TransformerAbstract
{
@ -23,6 +24,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;
return [
'_v' => 1,
@ -34,7 +36,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
'in_reply_to_id' => $status->in_reply_to_id ? (string) $status->in_reply_to_id : null,
'in_reply_to_account_id' => $status->in_reply_to_profile_id ? (string) $status->in_reply_to_profile_id : null,
'reblog' => $status->reblog_of_id ? StatusService::get($status->reblog_of_id, false) : null,
'content' => $status->rendered ?? $status->caption,
'content' => $rendered,
'content_text' => $status->caption,
'created_at' => str_replace('+00:00', 'Z', $status->created_at->format(DATE_RFC3339_EXTENDED)),
'emojis' => CustomEmoji::scan($status->caption),

View File

@ -19,6 +19,7 @@ use Illuminate\Support\Str;
use App\Services\PollService;
use App\Models\CustomEmoji;
use App\Services\BookmarkService;
use App\Util\Lexer\Autolink;
class StatusTransformer extends Fractal\TransformerAbstract
{
@ -27,6 +28,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;
$rendered = $status->caption ? Autolink::create()->autolink($status->caption) : null;
return [
'_v' => 1,
@ -37,7 +39,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
'in_reply_to_id' => (string) $status->in_reply_to_id,
'in_reply_to_account_id' => (string) $status->in_reply_to_profile_id,
'reblog' => $status->reblog_of_id ? StatusService::get($status->reblog_of_id) : null,
'content' => $status->rendered ?? $status->caption,
'content' => $rendered,
'content_text' => $status->caption,
'created_at' => str_replace('+00:00', 'Z', $status->created_at->format(DATE_RFC3339_EXTENDED)),
'emojis' => CustomEmoji::scan($status->caption),