Merge pull request #4404 from pixelfed/staging

Update MediaController, add fallback for local files that are later s…
This commit is contained in:
daniel 2023-05-22 18:12:55 -06:00 committed by GitHub
commit 01c0902b3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View file

@ -48,6 +48,7 @@
- Update admin moderation logic, only re-add top level posts ([c6ffda96](https://github.com/pixelfed/pixelfed/commit/c6ffda96))
- Update admin dashboard, add mass account deletes ([b8426cce](https://github.com/pixelfed/pixelfed/commit/b8426cce))
- Update scheduler, fix S3 media garbage collection not being executed when cloud storage is enabled via dashboard without .env/config being enabled ([adb070f1](https://github.com/pixelfed/pixelfed/commit/adb070f1))
- Update MediaController, add fallback for local files that are later stored on S3 but still are referenced in cached objects remotely ([4973cb46](https://github.com/pixelfed/pixelfed/commit/4973cb46))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.6 (2023-05-03)](https://github.com/pixelfed/pixelfed/compare/v0.11.5...v0.11.6)

View file

@ -3,18 +3,10 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth, Storage, URL;
use App\Media;
use Image as Intervention;
use App\Jobs\ImageOptimizePipeline\ImageOptimize;
class MediaController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(Request $request)
{
//return view('settings.drive.index');
@ -24,4 +16,16 @@ class MediaController extends Controller
{
abort(400, 'Endpoint deprecated');
}
public function fallbackRedirect(Request $request, $pid, $mhash, $uhash, $f)
{
abort_if(!config_cache('pixelfed.cloud_storage'), 404);
$path = 'public/m/_v2/' . $pid . '/' . $mhash . '/' . $uhash . '/' . $f;
$media = Media::whereProfileId($pid)
->whereMediaPath($path)
->whereNotNull('cdn_url')
->firstOrFail();
return redirect()->away($media->cdn_url);
}
}

View file

@ -616,6 +616,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('auth/invite/a/{code}', 'AdminInviteController@index');
Route::post('api/v1.1/auth/invite/admin/re', 'AdminInviteController@apiRegister')->middleware('throttle:5,1440');
Route::get('storage/m/_v2/{pid}/{mhash}/{uhash}/{f}', 'MediaController@fallbackRedirect');
Route::get('stories/{username}', 'ProfileController@stories');
Route::get('p/{id}', 'StatusController@shortcodeRedirect');
Route::get('c/{collection}', 'CollectionController@show');