mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-11 14:40:46 +00:00
Update MediaController, remove deprecated endpoint
This commit is contained in:
parent
57fa889d16
commit
8132db74e5
1 changed files with 1 additions and 34 deletions
|
@ -22,39 +22,6 @@ class MediaController extends Controller
|
||||||
|
|
||||||
public function composeUpdate(Request $request, $id)
|
public function composeUpdate(Request $request, $id)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
abort(404);
|
||||||
'file' => function() {
|
|
||||||
return [
|
|
||||||
'required',
|
|
||||||
'mimes:' . config('pixelfed.media_types'),
|
|
||||||
'max:' . config('pixelfed.max_photo_size'),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
$user = Auth::user();
|
|
||||||
|
|
||||||
$photo = $request->file('file');
|
|
||||||
|
|
||||||
$media = Media::whereUserId($user->id)
|
|
||||||
->whereProfileId($user->profile_id)
|
|
||||||
->whereNull('status_id')
|
|
||||||
->findOrFail($id);
|
|
||||||
|
|
||||||
$media->version = 2;
|
|
||||||
$media->save();
|
|
||||||
|
|
||||||
$fragments = explode('/', $media->media_path);
|
|
||||||
$name = last($fragments);
|
|
||||||
array_pop($fragments);
|
|
||||||
$dir = implode('/', $fragments);
|
|
||||||
$path = $photo->storeAs($dir, $name);
|
|
||||||
$res = [];
|
|
||||||
$res['url'] = URL::temporarySignedRoute(
|
|
||||||
'temp-media', now()->addHours(1), ['profileId' => $media->profile_id, 'mediaId' => $media->id, 'timestamp' => time()]
|
|
||||||
);
|
|
||||||
ImageOptimize::dispatch($media);
|
|
||||||
return $res;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue