mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 15:03:17 +00:00
commit
7290445f78
3 changed files with 69 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
|||
- Updated InternalApiController, update discoverPosts method to improve performance. ([9862a855](https://github.com/pixelfed/pixelfed/commit/9862a855))
|
||||
- Updated DiscoverComponent, add blurhash and like/comment counts. ([a8ebdd2e](https://github.com/pixelfed/pixelfed/commit/a8ebdd2e))
|
||||
- Updated DiscoverComponent, add spinner loaders and remove deprecated sections. ([34869247](https://github.com/pixelfed/pixelfed/commit/34869247))
|
||||
- Updated AccountController, add mutes and blocks endpoint to pixelfed api. ([1fb7e2b2](https://github.com/pixelfed/pixelfed/commit/1fb7e2b2))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
||||
|
|
|
@ -22,6 +22,10 @@ use App\{
|
|||
User,
|
||||
UserFilter
|
||||
};
|
||||
use League\Fractal;
|
||||
use League\Fractal\Serializer\ArraySerializer;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use App\Transformer\Api\Mastodon\v1\AccountTransformer;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
|
@ -487,4 +491,66 @@ class AccountController extends Controller
|
|||
public function accountRestored(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function accountMutes(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'limit' => 'nullable|integer|min:1|max:40'
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
$limit = $request->input('limit') ?? 40;
|
||||
|
||||
$mutes = UserFilter::whereUserId($user->profile_id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereFilterType('mute')
|
||||
->simplePaginate($limit)
|
||||
->pluck('filterable_id');
|
||||
|
||||
$accounts = Profile::find($mutes);
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Collection($accounts, new AccountTransformer());
|
||||
$res = $fractal->createData($resource)->toArray();
|
||||
$url = $request->url();
|
||||
$page = $request->input('page', 1);
|
||||
$next = $page < 40 ? $page + 1 : 40;
|
||||
$prev = $page > 1 ? $page - 1 : 1;
|
||||
$links = '<'.$url.'?page='.$next.'&limit='.$limit.'>; rel="next", <'.$url.'?page='.$prev.'&limit='.$limit.'>; rel="prev"';
|
||||
return response()->json($res, 200, ['Link' => $links]);
|
||||
}
|
||||
|
||||
public function accountBlocks(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'limit' => 'nullable|integer|min:1|max:40',
|
||||
'page' => 'nullable|integer|min:1|max:10'
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
$limit = $request->input('limit') ?? 40;
|
||||
|
||||
$blocked = UserFilter::select('filterable_id','filterable_type','filter_type','user_id')
|
||||
->whereUserId($user->profile_id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereFilterType('block')
|
||||
->simplePaginate($limit)
|
||||
->pluck('filterable_id');
|
||||
|
||||
$profiles = Profile::findOrFail($blocked);
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Collection($profiles, new AccountTransformer());
|
||||
$res = $fractal->createData($resource)->toArray();
|
||||
$url = $request->url();
|
||||
$page = $request->input('page', 1);
|
||||
$next = $page < 40 ? $page + 1 : 40;
|
||||
$prev = $page > 1 ? $page - 1 : 1;
|
||||
$links = '<'.$url.'?page='.$next.'&limit='.$limit.'>; rel="next", <'.$url.'?page='.$prev.'&limit='.$limit.'>; rel="prev"';
|
||||
return response()->json($res, 200, ['Link' => $links]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,6 +172,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('newsroom/timeline', 'NewsroomController@timelineApi');
|
||||
Route::post('newsroom/markasread', 'NewsroomController@markAsRead');
|
||||
Route::get('favourites', 'Api\BaseApiController@accountLikes');
|
||||
Route::get('mutes', 'AccountController@accountMutes');
|
||||
Route::get('blocks', 'AccountController@accountBlocks');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'v2'], function() {
|
||||
|
|
Loading…
Reference in a new issue