Update AP Helpers

This commit is contained in:
Daniel Supernault 2019-07-18 22:08:39 -06:00
parent 8e942994d6
commit a60f167d49
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 3 additions and 16 deletions

View File

@ -361,29 +361,16 @@ class Helpers {
if(in_array($type, $allowed) == false || $valid == false) {
continue;
}
$info = pathinfo($url);
// pleroma attachment fix
$url = str_replace(' ', '%20', $url);
$img = file_get_contents($url, false, stream_context_create(['ssl' => ["verify_peer"=>true,"verify_peer_name"=>true]]));
$file = '/tmp/pxmi-'.str_random(32);
file_put_contents($file, $img);
$fdata = new File($file);
$path = Storage::putFile($storagePath, $fdata, 'public');
$media = new Media();
$media->remote_media = true;
$media->status_id = $status->id;
$media->profile_id = $status->profile_id;
$media->user_id = null;
$media->media_path = $path;
$media->size = $fdata->getSize();
$media->mime = $fdata->getMimeType();
$media->media_path = $url;
$media->remote_url = $url;
$media->mime = $type;
$media->save();
ImageThumbnail::dispatch($media);
ImageOptimize::dispatch($media);
unlink($file);
}
$status->viewType();