forked from mirror/pixelfed
Update BaseApiController
This commit is contained in:
parent
a1c29b50e3
commit
76f6514293
|
@ -48,7 +48,8 @@ class BaseApiController extends Controller
|
||||||
public function notifications(Request $request)
|
public function notifications(Request $request)
|
||||||
{
|
{
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
if(config('exp.ns') == false) {
|
$pg = $request->input('pg');
|
||||||
|
if($pg == true) {
|
||||||
$timeago = Carbon::now()->subMonths(6);
|
$timeago = Carbon::now()->subMonths(6);
|
||||||
$notifications = Notification::whereProfileId($pid)
|
$notifications = Notification::whereProfileId($pid)
|
||||||
->whereDate('created_at', '>', $timeago)
|
->whereDate('created_at', '>', $timeago)
|
||||||
|
@ -272,6 +273,7 @@ class BaseApiController extends Controller
|
||||||
'temp-media', now()->addHours(1), ['profileId' => $profile->id, 'mediaId' => $media->id]
|
'temp-media', now()->addHours(1), ['profileId' => $profile->id, 'mediaId' => $media->id]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$preview_url = $url;
|
||||||
switch ($media->mime) {
|
switch ($media->mime) {
|
||||||
case 'image/jpeg':
|
case 'image/jpeg':
|
||||||
case 'image/png':
|
case 'image/png':
|
||||||
|
@ -280,6 +282,8 @@ class BaseApiController extends Controller
|
||||||
|
|
||||||
case 'video/mp4':
|
case 'video/mp4':
|
||||||
VideoThumbnail::dispatch($media);
|
VideoThumbnail::dispatch($media);
|
||||||
|
$preview_url = '/storage/no-preview.png';
|
||||||
|
$url = '/storage/no-preview.png';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -288,7 +292,7 @@ class BaseApiController extends Controller
|
||||||
|
|
||||||
$resource = new Fractal\Resource\Item($media, new MediaTransformer());
|
$resource = new Fractal\Resource\Item($media, new MediaTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
$res['preview_url'] = $url;
|
$res['preview_url'] = $preview_url;
|
||||||
$res['url'] = $url;
|
$res['url'] = $url;
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
@ -327,4 +331,34 @@ class BaseApiController extends Controller
|
||||||
return response()->json($res);
|
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 New Issue