1
0
Fork 0
forked from mirror/pixelfed

Update Status model, allow unlisted thumbnails

This commit is contained in:
Daniel Supernault 2023-09-25 02:10:19 -06:00
parent 2d428f43e8
commit 1f0a45b7f4
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -97,7 +97,7 @@ class Status extends Model
public function thumb($showNsfw = false)
{
$entity = StatusService::get($this->id);
$entity = StatusService::get($this->id, false);
if(!$entity || !isset($entity['media_attachments']) || empty($entity['media_attachments'])) {
return url(Storage::url('public/no-preview.png'));
@ -107,6 +107,10 @@ class Status extends Model
return url(Storage::url('public/no-preview.png'));
}
if(!isset($entity['visibility']) || !in_array($entity['visibility'], ['public', 'unlisted'])) {
return url(Storage::url('public/no-preview.png'));
}
return collect($entity['media_attachments'])
->filter(fn($media) => $media['type'] == 'image' && in_array($media['mime'], ['image/jpeg', 'image/png']))
->map(function($media) {