diff --git a/app/Http/Controllers/ComposeController.php b/app/Http/Controllers/ComposeController.php index bada3cd6..d2003ddd 100644 --- a/app/Http/Controllers/ComposeController.php +++ b/app/Http/Controllers/ComposeController.php @@ -513,4 +513,39 @@ class ComposeController extends Controller return $status->url(); } + + public function mediaProcessingCheck(Request $request) + { + $this->validate($request, [ + 'id' => 'required|integer|min:1' + ]); + + $media = Media::whereUserId($request->user()->id) + ->whereNull('status_id') + ->findOrFail($request->input('id')); + + if(config('pixelfed.media_fast_process')) { + return [ + 'finished' => true + ]; + } + + $finished = false; + + switch ($media->mime) { + case 'image/jpeg': + case 'image/png': + case 'video/mp4': + $finished = config('pixelfed.cloud_storage') ? (bool) $media->cdn_url : (bool) $media->processed_at; + break; + + default: + # code... + break; + } + + return [ + 'finished' => $finished + ]; + } }