Merge pull request #7424 from lilithmooncohen/fix/remote-content-preserves-html

Preserve the delivered HTML for remote status content
pull/7426/head
dansup 1 day ago committed by GitHub
commit c077117c45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -328,6 +328,7 @@ class InternalApiController extends Controller
'id',
'uri',
'caption',
'rendered',
'profile_id',
'type',
'in_reply_to_id',

@ -179,7 +179,7 @@ class PublicApiController extends Controller
$replies = $status->comments()
->whereNull('reblog_of_id')
->whereIn('scope', $scope)
->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->select('id', 'caption', 'rendered', 'local', 'visibility', 'scope', 'is_nsfw', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->where('id', '>=', $request->min_id)
->orderBy('id', 'desc')
->paginate($limit);
@ -188,7 +188,7 @@ class PublicApiController extends Controller
$replies = $status->comments()
->whereNull('reblog_of_id')
->whereIn('scope', $scope)
->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->select('id', 'caption', 'rendered', 'local', 'visibility', 'scope', 'is_nsfw', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->where('id', '<=', $request->max_id)
->orderBy('id', 'desc')
->paginate($limit);
@ -197,7 +197,7 @@ class PublicApiController extends Controller
$replies = Status::whereInReplyToId($status->id)
->whereNull('reblog_of_id')
->whereIn('scope', $scope)
->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->select('id', 'caption', 'rendered', 'local', 'visibility', 'scope', 'is_nsfw', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->orderBy('id', 'desc')
->paginate($limit);
}

@ -340,7 +340,10 @@ class SearchController extends Controller
if ($media) {
$url = $media->remote_url;
}
$content = $item->caption ? Autolink::create()->autolink($item->caption) : null;
// Remote posts keep the HTML they arrived with, so the link targets survive
$content = $item->local || ! $item->rendered
? ($item->caption ? Autolink::create()->autolink($item->caption) : null)
: $item->rendered;
$this->tokens['posts'] = [[
'count' => 0,
'url' => "/i/web/post/_/$item->profile_id/$item->id",
@ -364,7 +367,10 @@ class SearchController extends Controller
if ($media) {
$url = $media->remote_url;
}
$content = $item->caption ? Autolink::create()->autolink($item->caption) : null;
// Remote posts keep the HTML they arrived with, so the link targets survive
$content = $item->local || ! $item->rendered
? ($item->caption ? Autolink::create()->autolink($item->caption) : null)
: $item->rendered;
$this->tokens['posts'] = [[
'count' => 0,
'url' => "/i/web/post/_/$item->profile_id/$item->id",

@ -22,7 +22,10 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
{
$taggedPeople = MediaTagService::get($status->id);
$poll = $status->type === 'poll' ? PollService::get($status->id) : null;
$rendered = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : '';
// Remote posts keep the HTML they arrived with, so the link targets survive
$rendered = $status->local || ! $status->rendered
? ($status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : '')
: $status->rendered;
return [
'_v' => 1,

@ -24,7 +24,10 @@ 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)) : '';
// Remote posts keep the HTML they arrived with, so the link targets survive
$content = $status->local || ! $status->rendered
? ($status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : '')
: $status->rendered;
return [
'_v' => 1,

Loading…
Cancel
Save