Merge pull request #4667 from pixelfed/staging

Update Status model, allow unlisted thumbnails
This commit is contained in:
daniel 2023-09-25 02:11:33 -06:00 committed by GitHub
commit b2195ca837
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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