Update ComposeController, add mediaProcessingCheck method

This commit is contained in:
Daniel Supernault 2021-02-05 21:15:13 -07:00
parent 6bee5072d0
commit 33b625f508
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -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
];
}
}