mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-12 17:44:31 +00:00
Update StatusRemoteUpdatePipeline, fix missing mime and size attributes that cause empty media previews on our mobile app
This commit is contained in:
parent
60747bfb15
commit
ea54413e95
1 changed files with 14 additions and 0 deletions
|
@ -15,6 +15,7 @@ use App\Status;
|
||||||
use App\Models\StatusEdit;
|
use App\Models\StatusEdit;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
use Purify;
|
use Purify;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class StatusRemoteUpdatePipeline implements ShouldQueue
|
class StatusRemoteUpdatePipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -89,13 +90,26 @@ class StatusRemoteUpdatePipeline implements ShouldQueue
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$nm->each(function($n, $key) use($status) {
|
$nm->each(function($n, $key) use($status) {
|
||||||
|
$res = Http::retry(3, 100, throw: false)->head($n['url']);
|
||||||
|
|
||||||
|
if(!$res->successful()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in_array($res->header('content-type'), explode(',',config('pixelfed.media_types')))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$m = new Media;
|
$m = new Media;
|
||||||
$m->status_id = $status->id;
|
$m->status_id = $status->id;
|
||||||
$m->profile_id = $status->profile_id;
|
$m->profile_id = $status->profile_id;
|
||||||
$m->remote_media = true;
|
$m->remote_media = true;
|
||||||
$m->media_path = $n['url'];
|
$m->media_path = $n['url'];
|
||||||
|
$m->mime = $res->header('content-type');
|
||||||
|
$m->size = $res->hasHeader('content-length') ? $res->header('content-length') : null;
|
||||||
$m->caption = isset($n['name']) && !empty($n['name']) ? Purify::clean($n['name']) : null;
|
$m->caption = isset($n['name']) && !empty($n['name']) ? Purify::clean($n['name']) : null;
|
||||||
$m->remote_url = $n['url'];
|
$m->remote_url = $n['url'];
|
||||||
|
$m->blurhash = isset($n['blurhash']) && (strlen($n['blurhash']) < 50) ? $n['blurhash'] : null;
|
||||||
$m->width = isset($n['width']) && !empty($n['width']) ? $n['width'] : null;
|
$m->width = isset($n['width']) && !empty($n['width']) ? $n['width'] : null;
|
||||||
$m->height = isset($n['height']) && !empty($n['height']) ? $n['height'] : null;
|
$m->height = isset($n['height']) && !empty($n['height']) ? $n['height'] : null;
|
||||||
$m->skip_optimize = true;
|
$m->skip_optimize = true;
|
||||||
|
|
Loading…
Reference in a new issue