mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Update StatusTransformers
This commit is contained in:
parent
21f262315d
commit
a79d23d152
3 changed files with 9 additions and 5 deletions
|
@ -267,7 +267,7 @@ class ApiV1Controller extends Controller
|
||||||
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
||||||
'since_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
'since_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
||||||
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
||||||
'limit' => 'nullable|integer|min:1|max:40'
|
'limit' => 'nullable|integer|min:1|max:80'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$profile = Profile::whereNull('status')->findOrFail($id);
|
$profile = Profile::whereNull('status')->findOrFail($id);
|
||||||
|
@ -748,6 +748,8 @@ class ApiV1Controller extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if($like->wasRecentlyCreated == true) {
|
if($like->wasRecentlyCreated == true) {
|
||||||
|
$status->likes_count = $status->likes()->count();
|
||||||
|
$status->save();
|
||||||
LikePipeline::dispatch($like);
|
LikePipeline::dispatch($like);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,6 +779,8 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
if($like) {
|
if($like) {
|
||||||
$like->delete();
|
$like->delete();
|
||||||
|
$status->likes_count = $status->likes()->count();
|
||||||
|
$status->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
|
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
|
||||||
|
|
|
@ -28,8 +28,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
'created_at' => $status->created_at->toJSON(),
|
'created_at' => $status->created_at->toJSON(),
|
||||||
'emojis' => [],
|
'emojis' => [],
|
||||||
'replies_count' => 0,
|
'replies_count' => 0,
|
||||||
'reblogs_count' => $status->reblogs_count,
|
'reblogs_count' => $status->reblogs_count ?? 0,
|
||||||
'favourites_count' => $status->likes_count,
|
'favourites_count' => $status->likes_count ?? 0,
|
||||||
'reblogged' => null,
|
'reblogged' => null,
|
||||||
'favourited' => null,
|
'favourited' => null,
|
||||||
'muted' => null,
|
'muted' => null,
|
||||||
|
|
|
@ -25,8 +25,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
'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->reblogs_count,
|
'reblogs_count' => $status->reblogs_count ?? 0,
|
||||||
'favourites_count' => $status->likes_count,
|
'favourites_count' => $status->likes_count ?? 0,
|
||||||
'reblogged' => $status->shared(),
|
'reblogged' => $status->shared(),
|
||||||
'favourited' => $status->liked(),
|
'favourited' => $status->liked(),
|
||||||
'muted' => null,
|
'muted' => null,
|
||||||
|
|
Loading…
Reference in a new issue