Update ApiV1Controller, add default license support

This commit is contained in:
Daniel Supernault 2021-07-24 22:20:05 -06:00
parent 833d110c9e
commit 2a791f1991
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -1091,6 +1091,17 @@ class ApiV1Controller extends Controller
$storagePath = MediaPathService::get($user, 2); $storagePath = MediaPathService::get($user, 2);
$path = $photo->store($storagePath); $path = $photo->store($storagePath);
$hash = \hash_file('sha256', $photo); $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); abort_if(MediaBlocklistService::exists($hash) == true, 451);
@ -1105,6 +1116,9 @@ class ApiV1Controller extends Controller
$media->caption = $request->input('description'); $media->caption = $request->input('description');
$media->filter_class = $filterClass; $media->filter_class = $filterClass;
$media->filter_name = $filterName; $media->filter_name = $filterName;
if($license) {
$media->license = $license;
}
$media->save(); $media->save();
switch ($media->mime) { switch ($media->mime) {