1
0
Fork 0
forked from mirror/pixelfed

Update Status model, fix thumb nsfw caching

This commit is contained in:
Daniel Supernault 2020-12-05 00:12:08 -07:00
parent 6ea1db538a
commit 327ef1384b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -89,7 +89,8 @@ class Status extends Model
public function thumb($showNsfw = false)
{
return Cache::remember('status:thumb:'.$this->id, now()->addMinutes(15), function() use ($showNsfw) {
$key = $showNsfw ? 'status:thumb:nsfw1'.$this->id : 'status:thumb:nsfw0'.$this->id;
return Cache::remember($key, now()->addMinutes(15), function() use ($showNsfw) {
$type = $this->type ?? $this->setType();
$is_nsfw = !$showNsfw ? $this->is_nsfw : false;
if ($this->media->count() == 0 || $is_nsfw || !in_array($type,['photo', 'photo:album', 'video'])) {