mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 23:13:17 +00:00
Update ApiV1Controller, improve timeline account hydration
This commit is contained in:
parent
5bf1c61efa
commit
4e79c77282
1 changed files with 21 additions and 3 deletions
|
@ -2130,6 +2130,10 @@ class ApiV1Controller extends Controller
|
|||
->get()
|
||||
->map(function($s) use($pid, $napi) {
|
||||
try {
|
||||
$account = $napi ? AccountService::get($s['profile_id'], true) : AccountService::getMastodon($s['profile_id'], true);
|
||||
if(!$account) {
|
||||
return false;
|
||||
}
|
||||
$status = $napi ? StatusService::get($s['id'], false) : StatusService::getMastodon($s['id'], false);
|
||||
if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
|
||||
return false;
|
||||
|
@ -2138,6 +2142,8 @@ class ApiV1Controller extends Controller
|
|||
return false;
|
||||
}
|
||||
|
||||
$status['account'] = $account;
|
||||
|
||||
if($pid) {
|
||||
$status['favourited'] = (bool) LikeService::liked($pid, $s['id']);
|
||||
$status['reblogged'] = (bool) ReblogService::get($pid, $status['id']);
|
||||
|
@ -2167,7 +2173,7 @@ class ApiV1Controller extends Controller
|
|||
->get()
|
||||
->map(function($s) use($pid, $napi) {
|
||||
try {
|
||||
$account = AccountService::get($s['profile_id'], true);
|
||||
$account = $napi ? AccountService::get($s['profile_id'], true) : AccountService::getMastodon($s['profile_id'], true);
|
||||
if(!$account) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2179,6 +2185,8 @@ class ApiV1Controller extends Controller
|
|||
return false;
|
||||
}
|
||||
|
||||
$status['account'] = $account;
|
||||
|
||||
if($pid) {
|
||||
$status['favourited'] = (bool) LikeService::liked($pid, $s['id']);
|
||||
$status['reblogged'] = (bool) ReblogService::get($pid, $status['id']);
|
||||
|
@ -2289,11 +2297,21 @@ class ApiV1Controller extends Controller
|
|||
}
|
||||
})
|
||||
->map(function($k) use($user, $napi) {
|
||||
$status = $napi ? StatusService::get($k) : StatusService::getMastodon($k);
|
||||
if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
|
||||
try {
|
||||
$status = $napi ? StatusService::get($k) : StatusService::getMastodon($k);
|
||||
} catch(\Exception $e) {
|
||||
if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$account = $napi ? AccountService::get($status['account']['id'], true) : AccountService::getMastodon($status['account']['id'], true);
|
||||
if(!$account) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$status['account'] = $account;
|
||||
|
||||
if($user) {
|
||||
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $k);
|
||||
$status['reblogged'] = (bool) ReblogService::get($user->profile_id, $status['id']);
|
||||
|
|
Loading…
Reference in a new issue