mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-02-24 07:00:46 +00:00
Update MediaController, fix redirect bug
This commit is contained in:
parent
f2f2dc7a4f
commit
dc4e683f0a
1 changed files with 11 additions and 4 deletions
|
@ -9,7 +9,6 @@ class MediaController extends Controller
|
|||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
//return view('settings.drive.index');
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
@ -20,13 +19,21 @@ class MediaController extends Controller
|
|||
|
||||
public function fallbackRedirect(Request $request, $pid, $mhash, $uhash, $f)
|
||||
{
|
||||
abort_if(! (bool) config_cache('pixelfed.cloud_storage'), 404);
|
||||
if (! (bool) config_cache('pixelfed.cloud_storage')) {
|
||||
return redirect('/storage/no-preview.png', 302);
|
||||
}
|
||||
|
||||
$path = 'public/m/_v2/'.$pid.'/'.$mhash.'/'.$uhash.'/'.$f;
|
||||
|
||||
$media = Media::whereProfileId($pid)
|
||||
->whereMediaPath($path)
|
||||
->whereNotNull('cdn_url')
|
||||
->firstOrFail();
|
||||
->first();
|
||||
|
||||
return redirect()->away($media->cdn_url);
|
||||
if (! $media) {
|
||||
return redirect('/storage/no-preview.png', 302);
|
||||
}
|
||||
|
||||
return redirect()->away($media->cdn_url, 302);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue