forked from mirror/pixelfed
Merge pull request #4702 from pixelfed/staging
Update StatusTransformer, generate autolink on request
This commit is contained in:
commit
7cbdac7adb
2 changed files with 6 additions and 2 deletions
|
@ -16,6 +16,7 @@ use App\Services\StatusLabelService;
|
||||||
use App\Services\StatusMentionService;
|
use App\Services\StatusMentionService;
|
||||||
use App\Services\PollService;
|
use App\Services\PollService;
|
||||||
use App\Models\CustomEmoji;
|
use App\Models\CustomEmoji;
|
||||||
|
use App\Util\Lexer\Autolink;
|
||||||
|
|
||||||
class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
|
@ -23,6 +24,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
$taggedPeople = MediaTagService::get($status->id);
|
$taggedPeople = MediaTagService::get($status->id);
|
||||||
$poll = $status->type === 'poll' ? PollService::get($status->id) : null;
|
$poll = $status->type === 'poll' ? PollService::get($status->id) : null;
|
||||||
|
$rendered = $status->caption ? Autolink::create()->autolink($status->caption) : null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'_v' => 1,
|
'_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_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,
|
'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,
|
'reblog' => $status->reblog_of_id ? StatusService::get($status->reblog_of_id, false) : null,
|
||||||
'content' => $status->rendered ?? $status->caption,
|
'content' => $rendered,
|
||||||
'content_text' => $status->caption,
|
'content_text' => $status->caption,
|
||||||
'created_at' => str_replace('+00:00', 'Z', $status->created_at->format(DATE_RFC3339_EXTENDED)),
|
'created_at' => str_replace('+00:00', 'Z', $status->created_at->format(DATE_RFC3339_EXTENDED)),
|
||||||
'emojis' => CustomEmoji::scan($status->caption),
|
'emojis' => CustomEmoji::scan($status->caption),
|
||||||
|
|
|
@ -19,6 +19,7 @@ use Illuminate\Support\Str;
|
||||||
use App\Services\PollService;
|
use App\Services\PollService;
|
||||||
use App\Models\CustomEmoji;
|
use App\Models\CustomEmoji;
|
||||||
use App\Services\BookmarkService;
|
use App\Services\BookmarkService;
|
||||||
|
use App\Util\Lexer\Autolink;
|
||||||
|
|
||||||
class StatusTransformer extends Fractal\TransformerAbstract
|
class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
|
@ -27,6 +28,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
$pid = request()->user()->profile_id;
|
$pid = request()->user()->profile_id;
|
||||||
$taggedPeople = MediaTagService::get($status->id);
|
$taggedPeople = MediaTagService::get($status->id);
|
||||||
$poll = $status->type === 'poll' ? PollService::get($status->id, $pid) : null;
|
$poll = $status->type === 'poll' ? PollService::get($status->id, $pid) : null;
|
||||||
|
$rendered = $status->caption ? Autolink::create()->autolink($status->caption) : null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'_v' => 1,
|
'_v' => 1,
|
||||||
|
@ -37,7 +39,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
'in_reply_to_id' => (string) $status->in_reply_to_id,
|
'in_reply_to_id' => (string) $status->in_reply_to_id,
|
||||||
'in_reply_to_account_id' => (string) $status->in_reply_to_profile_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,
|
'reblog' => $status->reblog_of_id ? StatusService::get($status->reblog_of_id) : null,
|
||||||
'content' => $status->rendered ?? $status->caption,
|
'content' => $rendered,
|
||||||
'content_text' => $status->caption,
|
'content_text' => $status->caption,
|
||||||
'created_at' => str_replace('+00:00', 'Z', $status->created_at->format(DATE_RFC3339_EXTENDED)),
|
'created_at' => str_replace('+00:00', 'Z', $status->created_at->format(DATE_RFC3339_EXTENDED)),
|
||||||
'emojis' => CustomEmoji::scan($status->caption),
|
'emojis' => CustomEmoji::scan($status->caption),
|
||||||
|
|
Loading…
Reference in a new issue