mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 08:13:16 +00:00
Update ApiV1Controller, fix accountStatusesById endpoint
This commit is contained in:
parent
15eccd443c
commit
db7b1af343
2 changed files with 11 additions and 9 deletions
|
@ -540,8 +540,11 @@ class ApiV1Controller extends Controller
|
||||||
'limit' => 'nullable|integer|min:1|max:100'
|
'limit' => 'nullable|integer|min:1|max:100'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$profile = AccountService::getMastodon($id);
|
$profile = AccountService::getMastodon($id, true);
|
||||||
abort_if(!$profile, 404);
|
|
||||||
|
if(!$profile || !isset($profile['id']) || !$user) {
|
||||||
|
return response('', 404);
|
||||||
|
}
|
||||||
|
|
||||||
$limit = $request->limit ?? 20;
|
$limit = $request->limit ?? 20;
|
||||||
$max_id = $request->max_id;
|
$max_id = $request->max_id;
|
||||||
|
@ -567,7 +570,9 @@ class ApiV1Controller extends Controller
|
||||||
$visibility = ['public', 'unlisted', 'private'];
|
$visibility = ['public', 'unlisted', 'private'];
|
||||||
} else if($profile['locked']) {
|
} else if($profile['locked']) {
|
||||||
$following = FollowerService::follows($pid, $profile['id']);
|
$following = FollowerService::follows($pid, $profile['id']);
|
||||||
abort_unless($following, 403);
|
if(!$following) {
|
||||||
|
return response('', 403);
|
||||||
|
}
|
||||||
$visibility = ['public', 'unlisted', 'private'];
|
$visibility = ['public', 'unlisted', 'private'];
|
||||||
} else {
|
} else {
|
||||||
$following = FollowerService::follows($pid, $profile['id']);
|
$following = FollowerService::follows($pid, $profile['id']);
|
||||||
|
@ -586,11 +591,8 @@ class ApiV1Controller extends Controller
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->get()
|
->get()
|
||||||
->map(function($s) use($user) {
|
->map(function($s) use($user) {
|
||||||
try {
|
$status = StatusService::getMastodon($s->id, false);
|
||||||
$status = StatusService::getMastodon($s->id, false);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$status = false;
|
|
||||||
}
|
|
||||||
if($user && $status) {
|
if($user && $status) {
|
||||||
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
|
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
||||||
Route::post('accounts/{id}/unmute', 'Api\ApiV1Controller@accountUnmuteById')->middleware($middleware);
|
Route::post('accounts/{id}/unmute', 'Api\ApiV1Controller@accountUnmuteById')->middleware($middleware);
|
||||||
Route::get('accounts/{id}/lists', 'Api\ApiV1Controller@accountListsById')->middleware($middleware);
|
Route::get('accounts/{id}/lists', 'Api\ApiV1Controller@accountListsById')->middleware($middleware);
|
||||||
Route::get('lists/{id}/accounts', 'Api\ApiV1Controller@accountListsById')->middleware($middleware);
|
Route::get('lists/{id}/accounts', 'Api\ApiV1Controller@accountListsById')->middleware($middleware);
|
||||||
Route::get('accounts/{id}', 'Api\ApiV1Controller@accountById');
|
Route::get('accounts/{id}', 'Api\ApiV1Controller@accountById')->middleware($middleware);
|
||||||
|
|
||||||
Route::post('avatar/update', 'ApiController@avatarUpdate')->middleware($middleware);
|
Route::post('avatar/update', 'ApiController@avatarUpdate')->middleware($middleware);
|
||||||
Route::get('blocks', 'Api\ApiV1Controller@accountBlocks')->middleware($middleware);
|
Route::get('blocks', 'Api\ApiV1Controller@accountBlocks')->middleware($middleware);
|
||||||
|
|
Loading…
Reference in a new issue