From 2a791f1991ab765c362e154780099286ed66686b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 24 Jul 2021 22:20:05 -0600 Subject: [PATCH] Update ApiV1Controller, add default license support --- app/Http/Controllers/Api/ApiV1Controller.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 801f96f9c..6a4593823 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1091,6 +1091,17 @@ class ApiV1Controller extends Controller $storagePath = MediaPathService::get($user, 2); $path = $photo->store($storagePath); $hash = \hash_file('sha256', $photo); + $license = null; + + $settings = UserSetting::whereUserId($user->id)->first(); + + if($settings && !empty($settings->compose_settings)) { + $compose = json_decode($settings->compose_settings, true); + + if(isset($compose['default_license']) && $compose['default_license'] != 1) { + $license = $compose['default_license']; + } + } abort_if(MediaBlocklistService::exists($hash) == true, 451); @@ -1105,6 +1116,9 @@ class ApiV1Controller extends Controller $media->caption = $request->input('description'); $media->filter_class = $filterClass; $media->filter_name = $filterName; + if($license) { + $media->license = $license; + } $media->save(); switch ($media->mime) {