mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update BaseApiController, add drafts method for Camera Roll
This commit is contained in:
parent
5773434a13
commit
bad2ecde56
1 changed files with 19 additions and 2 deletions
|
@ -20,6 +20,7 @@ use App\Transformer\Api\{
|
||||||
AccountTransformer,
|
AccountTransformer,
|
||||||
NotificationTransformer,
|
NotificationTransformer,
|
||||||
MediaTransformer,
|
MediaTransformer,
|
||||||
|
MediaDraftTransformer,
|
||||||
StatusTransformer
|
StatusTransformer
|
||||||
};
|
};
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
@ -307,8 +308,9 @@ class BaseApiController extends Controller
|
||||||
|
|
||||||
public function verifyCredentials(Request $request)
|
public function verifyCredentials(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
$user = $request->user();
|
||||||
$id = Auth::id();
|
abort_if(!$user, 403);
|
||||||
|
$id = $user->id;
|
||||||
|
|
||||||
$res = Cache::remember('user:account:id:'.$id, now()->addHours(6), function() use($id) {
|
$res = Cache::remember('user:account:id:'.$id, now()->addHours(6), function() use($id) {
|
||||||
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
||||||
|
@ -319,4 +321,19 @@ class BaseApiController extends Controller
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function drafts(Request $request)
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$medias = Media::whereUserId($user->id)
|
||||||
|
->whereNull('status_id')
|
||||||
|
->latest()
|
||||||
|
->take(13)
|
||||||
|
->get();
|
||||||
|
$resource = new Fractal\Resource\Collection($medias, new MediaDraftTransformer());
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue