mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update StatusController
This commit is contained in:
parent
3d7c97b0ed
commit
71393514b2
2 changed files with 41 additions and 1 deletions
|
@ -92,6 +92,8 @@ class StatusController extends Controller
|
||||||
|
|
||||||
$photos = $request->file('photo');
|
$photos = $request->file('photo');
|
||||||
$order = 1;
|
$order = 1;
|
||||||
|
$mimes = [];
|
||||||
|
|
||||||
foreach ($photos as $k => $v) {
|
foreach ($photos as $k => $v) {
|
||||||
$storagePath = "public/m/{$monthHash}/{$userHash}";
|
$storagePath = "public/m/{$monthHash}/{$userHash}";
|
||||||
$path = $v->store($storagePath);
|
$path = $v->store($storagePath);
|
||||||
|
@ -108,10 +110,14 @@ class StatusController extends Controller
|
||||||
$media->filter_name = $request->input('filter_name');
|
$media->filter_name = $request->input('filter_name');
|
||||||
$media->order = $order;
|
$media->order = $order;
|
||||||
$media->save();
|
$media->save();
|
||||||
|
array_push($mimes, $media->mime);
|
||||||
ImageOptimize::dispatch($media);
|
ImageOptimize::dispatch($media);
|
||||||
$order++;
|
$order++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$status->type = $this->mimeTypeCheck($mimes);
|
||||||
|
$status->save();
|
||||||
|
|
||||||
NewStatusPipeline::dispatch($status);
|
NewStatusPipeline::dispatch($status);
|
||||||
|
|
||||||
// TODO: Send to subscribers
|
// TODO: Send to subscribers
|
||||||
|
@ -254,4 +260,38 @@ class StatusController extends Controller
|
||||||
$allowed = ['public', 'unlisted', 'private'];
|
$allowed = ['public', 'unlisted', 'private'];
|
||||||
return in_array($visibility, $allowed) ? $visibility : 'public';
|
return in_array($visibility, $allowed) ? $visibility : 'public';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function mimeTypeCheck($mimes)
|
||||||
|
{
|
||||||
|
$allowed = explode(',', config('pixelfed.media_types'));
|
||||||
|
$count = count($mimes);
|
||||||
|
$photos = 0;
|
||||||
|
$videos = 0;
|
||||||
|
foreach($mimes as $mime) {
|
||||||
|
if(in_array($mime, $allowed) == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(str_contains($mime, 'image/')) {
|
||||||
|
$photos++;
|
||||||
|
}
|
||||||
|
if(str_contains($mime, 'video/')) {
|
||||||
|
$videos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($photos == 1 && $videos == 0) {
|
||||||
|
return 'photo';
|
||||||
|
}
|
||||||
|
if($videos == 1 && $photos == 0) {
|
||||||
|
return 'video';
|
||||||
|
}
|
||||||
|
if($photos > 1 && $videos == 0) {
|
||||||
|
return 'photo:album';
|
||||||
|
}
|
||||||
|
if($videos > 1 && $photos == 0) {
|
||||||
|
return 'video:album';
|
||||||
|
}
|
||||||
|
if($photos >= 1 && $videos >= 1) {
|
||||||
|
return 'photo:video:album';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Status extends Model
|
||||||
'photo:album',
|
'photo:album',
|
||||||
'video',
|
'video',
|
||||||
'video:album',
|
'video:album',
|
||||||
'photo:video:album'
|
'photo:video:album',
|
||||||
'share',
|
'share',
|
||||||
'reply',
|
'reply',
|
||||||
'story',
|
'story',
|
||||||
|
|
Loading…
Reference in a new issue