Merge pull request #5382 from pixelfed/staging

Update ApiV1Controller.php
This commit is contained in:
daniel 2024-12-06 05:05:31 -07:00 committed by GitHub
commit a430e15267
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1426,6 +1426,8 @@ class ApiV1Controller extends Controller
$status['favourited'] = true; $status['favourited'] = true;
$status['favourites_count'] = $status['favourites_count'] + 1; $status['favourites_count'] = $status['favourites_count'] + 1;
$status['bookmarked'] = BookmarkService::get($user->profile_id, $status['id']);
$status['reblogged'] = ReblogService::get($user->profile_id, $status['id']);
return $this->json($status); return $this->json($status);
} }
@ -1484,6 +1486,8 @@ class ApiV1Controller extends Controller
$status['favourited'] = false; $status['favourited'] = false;
$status['favourites_count'] = isset($ogStatus) ? $ogStatus->likes_count : $status['favourites_count'] - 1; $status['favourites_count'] = isset($ogStatus) ? $ogStatus->likes_count : $status['favourites_count'] - 1;
$status['bookmarked'] = BookmarkService::get($user->profile_id, $status['id']);
$status['reblogged'] = ReblogService::get($user->profile_id, $status['id']);
return $this->json($status); return $this->json($status);
} }
@ -3490,7 +3494,7 @@ class ApiV1Controller extends Controller
return []; return [];
} }
$content = $request->filled('status') ? strip_tags(Purify::clean($request->input('status'))) : null; $content = $request->filled('status') ? strip_tags($request->input('status')) : null;
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false); $cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null; $spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
@ -3695,6 +3699,8 @@ class ApiV1Controller extends Controller
ReblogService::add($user->profile_id, $status->id); ReblogService::add($user->profile_id, $status->id);
$res = StatusService::getMastodon($status->id); $res = StatusService::getMastodon($status->id);
$res['reblogged'] = true; $res['reblogged'] = true;
$res['favourited'] = LikeService::liked($user->profile_id, $status->id);
$res['bookmarked'] = BookmarkService::get($user->profile_id, $status->id);
return $this->json($res); return $this->json($res);
} }
@ -3741,6 +3747,8 @@ class ApiV1Controller extends Controller
$res = StatusService::getMastodon($status->id); $res = StatusService::getMastodon($status->id);
$res['reblogged'] = false; $res['reblogged'] = false;
$res['favourited'] = LikeService::liked($user->profile_id, $status->id);
$res['bookmarked'] = BookmarkService::get($user->profile_id, $status->id);
return $this->json($res); return $this->json($res);
} }