Update Instagram Imports

pull/7303/head
Daniel Supernault 1 week ago
parent 5cb1136679
commit 68b1a55960
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -131,6 +131,10 @@ class TransformImports extends Command
foreach ($ip->media as $ipm) {
$fileName = last(explode('/', $ipm['uri']));
$ext = last(explode('.', $fileName));
$ext = strtolower(last(explode('.', $fileName)));
if (! in_array($ext, ['jpg', 'jpeg', 'png', 'webp', 'mp4'], true)) {
continue;
}
$basePath = MediaPathService::get($profile);
$og = 'imports/'.$id.'/'.$fileName;
if (! $disk->exists($og)) {

@ -9,10 +9,19 @@ use App\Models\User;
use App\Services\ImportService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Log;
class ImportPostController extends Controller
{
public const ALLOWED_EXTENSIONS = [
'image/jpeg' => ['jpg', 'jpeg'],
'image/jpg' => ['jpg', 'jpeg'],
'image/png' => ['png'],
'image/webp' => ['webp'],
'video/mp4' => ['mp4'],
];
public function __construct()
{
$this->middleware('auth');
@ -223,6 +232,20 @@ class ImportPostController extends Controller
'file',
$mimes,
'max:'.config_cache('pixelfed.max_photo_size'),
function ($attribute, $value, $fail) {
if (! $value instanceof UploadedFile) {
$fail('The '.$attribute.' must be a file.');
return;
}
$mime = $value->getMimeType();
$ext = strtolower($value->getClientOriginalExtension());
if (! in_array($ext, self::ALLOWED_EXTENSIONS[$mime] ?? [], true)) {
$fail('The '.$attribute.' extension does not match its content.');
}
},
],
]);

Loading…
Cancel
Save