mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update api routes
This commit is contained in:
parent
74f576c8ce
commit
0a82e9466d
2 changed files with 19 additions and 11 deletions
|
@ -17,6 +17,7 @@ use App\Transformer\Api\{
|
||||||
};
|
};
|
||||||
use League\Fractal\Serializer\ArraySerializer;
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use App\Services\AccountService;
|
||||||
use App\Services\CollectionService;
|
use App\Services\CollectionService;
|
||||||
use App\Services\FollowerService;
|
use App\Services\FollowerService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
|
@ -222,32 +223,33 @@ class CollectionController extends Controller
|
||||||
$follows = false;
|
$follows = false;
|
||||||
$visibility = ['public'];
|
$visibility = ['public'];
|
||||||
|
|
||||||
$profile = Profile::whereNull('status')
|
$profile = AccountService::get($id, true);
|
||||||
->whereNull('domain')
|
if(!$profile || !isset($profile['id'])) {
|
||||||
->findOrFail($id);
|
return response()->json([], 404);
|
||||||
|
}
|
||||||
|
|
||||||
if($pid) {
|
if($pid) {
|
||||||
$follows = FollowerService::follows($pid, $profile->id);
|
$follows = FollowerService::follows($pid, $profile['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($profile->is_private) {
|
if($profile['locked']) {
|
||||||
abort_if(!$pid, 404);
|
abort_if(!$pid, 404);
|
||||||
if(!$user->is_admin) {
|
if(!$user->is_admin) {
|
||||||
abort_if($profile->id != $pid && $follows == false, 404);
|
abort_if($profile['id'] != $pid && $follows == false, 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = $pid ? $pid == $profile->id : false;
|
$owner = $pid ? $pid == $profile['id'] : false;
|
||||||
|
|
||||||
if($follows) {
|
if($follows) {
|
||||||
$visibility = ['public', 'private'];
|
$visibility = ['public', 'private'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pid && $pid == $profile->id) {
|
if($pid && $pid == $profile['id']) {
|
||||||
$visibility = ['public', 'private', 'draft'];
|
$visibility = ['public', 'private', 'draft'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collection::whereProfileId($profile->id)
|
return Collection::whereProfileId($profile['id'])
|
||||||
->whereIn('visibility', $visibility)
|
->whereIn('visibility', $visibility)
|
||||||
->when(!$owner, function($q, $owner) {
|
->when(!$owner, function($q, $owner) {
|
||||||
return $q->whereNotNull('published_at');
|
return $q->whereNotNull('published_at');
|
||||||
|
|
|
@ -110,6 +110,12 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
||||||
Route::get('apps-and-applications', 'Api\ApiV1Dot1Controller@accountApps')->middleware($middleware);
|
Route::get('apps-and-applications', 'Api\ApiV1Dot1Controller@accountApps')->middleware($middleware);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'collections'], function () use($middleware) {
|
||||||
|
Route::get('accounts/{id}', 'CollectionController@getUserCollections')->middleware($middleware);
|
||||||
|
Route::get('items/{id}', 'CollectionController@getItems')->middleware($middleware);
|
||||||
|
Route::get('view/{id}', 'CollectionController@getCollection')->middleware($middleware);
|
||||||
|
});
|
||||||
|
|
||||||
Route::group(['prefix' => 'direct'], function () use($middleware) {
|
Route::group(['prefix' => 'direct'], function () use($middleware) {
|
||||||
Route::get('thread', 'DirectMessageController@thread')->middleware($middleware);
|
Route::get('thread', 'DirectMessageController@thread')->middleware($middleware);
|
||||||
Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware);
|
Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware);
|
||||||
|
|
Loading…
Reference in a new issue