1
0
Fork 0
forked from mirror/pixelfed

Update StatusTransformer

This commit is contained in:
Daniel Supernault 2019-02-16 11:48:24 -07:00
parent 7b7ce8ea8a
commit 6fc752b5ad
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -17,35 +17,33 @@ class StatusTransformer extends Fractal\TransformerAbstract
public function transform(Status $status) public function transform(Status $status)
{ {
return Cache::remember('transform:status:'. $status->url(), 60, function() use($status) { return [
return [ 'id' => (string) $status->id,
'id' => (string) $status->id, 'uri' => $status->url(),
'uri' => $status->url(), 'url' => $status->url(),
'url' => $status->url(), 'in_reply_to_id' => $status->in_reply_to_id,
'in_reply_to_id' => $status->in_reply_to_id, 'in_reply_to_account_id' => $status->in_reply_to_profile_id,
'in_reply_to_account_id' => $status->in_reply_to_profile_id, 'reblog' => $status->reblog_of_id || $status->in_reply_to_id ? $this->transform($status->parent()) : null,
'reblog' => $status->reblog_of_id || $status->in_reply_to_id ? $this->transform($status->parent()) : null, 'content' => $status->rendered ?? $status->caption,
'content' => $status->rendered ?? $status->caption, 'created_at' => $status->created_at->format('c'),
'created_at' => $status->created_at->format('c'), 'emojis' => [],
'emojis' => [], 'reblogs_count' => $status->shares()->count(),
'reblogs_count' => $status->shares()->count(), 'favourites_count' => $status->likes()->count(),
'favourites_count' => $status->likes()->count(), 'reblogged' => $status->shared(),
'reblogged' => $status->shared(), 'favourited' => $status->liked(),
'favourited' => $status->liked(), 'muted' => null,
'muted' => null, 'sensitive' => (bool) $status->is_nsfw,
'sensitive' => (bool) $status->is_nsfw, 'spoiler_text' => $status->cw_summary,
'spoiler_text' => $status->cw_summary, 'visibility' => $status->visibility,
'visibility' => $status->visibility, 'application' => [
'application' => [ 'name' => 'web',
'name' => 'web', 'website' => null
'website' => null ],
], 'language' => null,
'language' => null, 'pinned' => null,
'pinned' => null,
'pf_type' => $status->type ?? $status->setType(), 'pf_type' => $status->type ?? $status->setType(),
]; ];
});
} }
public function includeAccount(Status $status) public function includeAccount(Status $status)