mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-19 11:00:46 +00:00
commit
7b5999496e
3 changed files with 22 additions and 11 deletions
|
@ -17,6 +17,7 @@
|
||||||
- Update NotificationService, improve cache warming query ([2496386d](https://github.com/pixelfed/pixelfed/commit/2496386d))
|
- Update NotificationService, improve cache warming query ([2496386d](https://github.com/pixelfed/pixelfed/commit/2496386d))
|
||||||
- Update StatusService, hydrate accounts on request instead of caching them along with status objects ([223661ec](https://github.com/pixelfed/pixelfed/commit/223661ec))
|
- Update StatusService, hydrate accounts on request instead of caching them along with status objects ([223661ec](https://github.com/pixelfed/pixelfed/commit/223661ec))
|
||||||
- Update profile embed, fix resize ([dc23c21d](https://github.com/pixelfed/pixelfed/commit/dc23c21d))
|
- Update profile embed, fix resize ([dc23c21d](https://github.com/pixelfed/pixelfed/commit/dc23c21d))
|
||||||
|
- Update Status model, improve thumb logic ([d969a973](https://github.com/pixelfed/pixelfed/commit/d969a973))
|
||||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)
|
## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)
|
||||||
|
|
|
@ -161,8 +161,6 @@ class StatusService
|
||||||
}
|
}
|
||||||
Cache::forget('status:transformer:media:attachments:' . $id);
|
Cache::forget('status:transformer:media:attachments:' . $id);
|
||||||
MediaService::del($id);
|
MediaService::del($id);
|
||||||
Cache::forget('status:thumb:nsfw0' . $id);
|
|
||||||
Cache::forget('status:thumb:nsfw1' . $id);
|
|
||||||
Cache::forget('pf:services:sh:id:' . $id);
|
Cache::forget('pf:services:sh:id:' . $id);
|
||||||
PublicTimelineService::rem($id);
|
PublicTimelineService::rem($id);
|
||||||
NetworkTimelineService::rem($id);
|
NetworkTimelineService::rem($id);
|
||||||
|
|
|
@ -9,7 +9,9 @@ use App\Http\Controllers\StatusController;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use App\Models\Poll;
|
use App\Models\Poll;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
|
use App\Services\StatusService;
|
||||||
use App\Models\StatusEdit;
|
use App\Models\StatusEdit;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Status extends Model
|
class Status extends Model
|
||||||
{
|
{
|
||||||
|
@ -95,16 +97,26 @@ class Status extends Model
|
||||||
|
|
||||||
public function thumb($showNsfw = false)
|
public function thumb($showNsfw = false)
|
||||||
{
|
{
|
||||||
$key = $showNsfw ? 'status:thumb:nsfw1'.$this->id : 'status:thumb:nsfw0'.$this->id;
|
$entity = StatusService::get($this->id);
|
||||||
return Cache::remember($key, now()->addMinutes(15), function() use ($showNsfw) {
|
|
||||||
$type = $this->type ?? $this->setType();
|
if(!$entity || !isset($entity['media_attachments']) || empty($entity['media_attachments'])) {
|
||||||
$is_nsfw = !$showNsfw ? $this->is_nsfw : false;
|
|
||||||
if ($this->media->count() == 0 || $is_nsfw || !in_array($type,['photo', 'photo:album', 'video'])) {
|
|
||||||
return url(Storage::url('public/no-preview.png'));
|
return url(Storage::url('public/no-preview.png'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return url(Storage::url($this->firstMedia()->thumbnail_path));
|
if((!isset($entity['sensitive']) || $entity['sensitive']) && !$showNsfw) {
|
||||||
});
|
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) {
|
||||||
|
if(!Str::endsWith($media['preview_url'], ['no-preview.png', 'no-preview.jpg'])) {
|
||||||
|
return $media['preview_url'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $media['url'];
|
||||||
|
})
|
||||||
|
->first() ?? url(Storage::url('public/no-preview.png'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function url($forceLocal = false)
|
public function url($forceLocal = false)
|
||||||
|
|
Loading…
Reference in a new issue