diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 61948f945..442ce41ba 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -978,6 +978,9 @@ class ApiV1Controller extends Controller } } + $filterClass = in_array($request->input('filter_class'), Filter::classes()) ? $request->input('filter_class') : null; + $filterName = in_array($request->input('filter_name'), Filter::names()) ? $request->input('filter_name') : null; + $monthHash = hash('sha1', date('Y').date('m')); $userHash = hash('sha1', $user->id . (string) $user->created_at); @@ -1001,8 +1004,8 @@ class ApiV1Controller extends Controller $media->size = $photo->getSize(); $media->mime = $photo->getMimeType(); $media->caption = $request->input('description'); - $media->filter_class = $request->input('filter_class'); - $media->filter_name = $request->input('filter_name'); + $media->filter_class = $filterClass; + $media->filter_name = $filterName; $media->save(); switch ($media->mime) { diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index e47d61e5e..a3a450c62 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -24,6 +24,7 @@ use App\Transformer\Api\{ StatusTransformer }; use League\Fractal; +use App\Util\Media\Filter; use League\Fractal\Serializer\ArraySerializer; use League\Fractal\Pagination\IlluminatePaginatorAdapter; use App\Jobs\AvatarPipeline\AvatarOptimize; @@ -231,6 +232,9 @@ class BaseApiController extends Controller } } + $filterClass = in_array($request->input('filter_class'), Filter::classes()) ? $request->input('filter_class') : null; + $filterName = in_array($request->input('filter_name'), Filter::names()) ? $request->input('filter_name') : null; + $monthHash = hash('sha1', date('Y').date('m')); $userHash = hash('sha1', $user->id . (string) $user->created_at); @@ -253,8 +257,8 @@ class BaseApiController extends Controller $media->original_sha256 = $hash; $media->size = $photo->getSize(); $media->mime = $photo->getMimeType(); - $media->filter_class = $request->input('filter_class'); - $media->filter_name = $request->input('filter_name'); + $media->filter_class = $filterClass; + $media->filter_name = $filterName; $media->save(); $url = URL::temporarySignedRoute( diff --git a/resources/views/status/edit.blade.php b/resources/views/status/edit.blade.php index f16aa2bf9..5d7203ade 100644 --- a/resources/views/status/edit.blade.php +++ b/resources/views/status/edit.blade.php @@ -38,7 +38,7 @@ @csrf
- +
@@ -69,12 +69,9 @@ @endsection @push('scripts') -