1
0
Fork 0
forked from mirror/pixelfed

Update BaseApiControllers

This commit is contained in:
Daniel Supernault 2018-11-04 17:09:45 -07:00
parent 6ba7c419fb
commit b5f452d4c1
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2,22 +2,27 @@
namespace App\Http\Controllers\Api;
use App\Avatar;
use App\Http\Controllers\AvatarController;
use App\Http\Controllers\Controller;
use App\Jobs\AvatarPipeline\AvatarOptimize;
use App\Jobs\ImageOptimizePipeline\ImageOptimize;
use App\Media;
use App\Profile;
use App\Transformer\Api\AccountTransformer;
use App\Transformer\Api\MediaTransformer;
use App\Transformer\Api\StatusTransformer;
use Auth;
use Cache;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL;
use App\Http\Controllers\{
Controller,
AvatarController
};
use Auth, Cache, URL;
use App\{Avatar,Media,Profile};
use App\Transformer\Api\{
AccountTransformer,
MediaTransformer,
StatusTransformer
};
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use App\Jobs\AvatarPipeline\AvatarOptimize;
use App\Jobs\ImageOptimizePipeline\ImageOptimize;
use App\Jobs\VideoPipeline\{
VideoOptimize,
VideoPostProcess,
VideoThumbnail
};
class BaseApiController extends Controller
{
@ -187,7 +192,20 @@ class BaseApiController extends Controller
$url = URL::temporarySignedRoute(
'temp-media', now()->addHours(1), ['profileId' => $profile->id, 'mediaId' => $media->id]
);
ImageOptimize::dispatch($media);
switch ($media->mime) {
case 'image/jpeg':
case 'image/png':
ImageOptimize::dispatch($media);
break;
case 'video/mp4':
VideoThumbnail::dispatch($media);
break;
default:
break;
}
$res = [
'id' => $media->id,