mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Update BaseApiController
This commit is contained in:
parent
a1c29b50e3
commit
76f6514293
1 changed files with 36 additions and 2 deletions
|
@ -48,7 +48,8 @@ class BaseApiController extends Controller
|
|||
public function notifications(Request $request)
|
||||
{
|
||||
$pid = Auth::user()->profile->id;
|
||||
if(config('exp.ns') == false) {
|
||||
$pg = $request->input('pg');
|
||||
if($pg == true) {
|
||||
$timeago = Carbon::now()->subMonths(6);
|
||||
$notifications = Notification::whereProfileId($pid)
|
||||
->whereDate('created_at', '>', $timeago)
|
||||
|
@ -272,6 +273,7 @@ class BaseApiController extends Controller
|
|||
'temp-media', now()->addHours(1), ['profileId' => $profile->id, 'mediaId' => $media->id]
|
||||
);
|
||||
|
||||
$preview_url = $url;
|
||||
switch ($media->mime) {
|
||||
case 'image/jpeg':
|
||||
case 'image/png':
|
||||
|
@ -280,6 +282,8 @@ class BaseApiController extends Controller
|
|||
|
||||
case 'video/mp4':
|
||||
VideoThumbnail::dispatch($media);
|
||||
$preview_url = '/storage/no-preview.png';
|
||||
$url = '/storage/no-preview.png';
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -288,7 +292,7 @@ class BaseApiController extends Controller
|
|||
|
||||
$resource = new Fractal\Resource\Item($media, new MediaTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
$res['preview_url'] = $url;
|
||||
$res['preview_url'] = $preview_url;
|
||||
$res['url'] = $url;
|
||||
return response()->json($res);
|
||||
}
|
||||
|
@ -327,4 +331,34 @@ class BaseApiController extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function loops(Request $request)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
abort_if(!config('exp.loops'), 403);
|
||||
|
||||
// todo proper pagination, maybe LoopService
|
||||
$loops = Status::whereType('video')
|
||||
->latest()
|
||||
->take(18)
|
||||
->get();
|
||||
|
||||
$resource = new Fractal\Resource\Collection($loops, new StatusTransformer());
|
||||
return $this->fractal->createData($resource)->toArray();
|
||||
}
|
||||
|
||||
|
||||
public function loopWatch(Request $request)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
abort_if(!config('exp.loops'), 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'id' => 'integer|min:1'
|
||||
]);
|
||||
$id = $request->input('id');
|
||||
|
||||
// todo log loops
|
||||
|
||||
return response()->json(200);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue