Update Status model

This commit is contained in:
Daniel Supernault 2019-05-27 12:58:54 -06:00
parent d09b00a70f
commit 402408e48c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -87,7 +87,7 @@ class Status extends Model
return Cache::remember('status:thumb:'.$this->id, 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'])) {
if ($this->media->count() == 0 || $is_nsfw || !in_array($type,['photo', 'photo:album', 'video'])) {
return url(Storage::url('public/no-preview.png'));
}
@ -99,11 +99,12 @@ class Status extends Model
{
if($this->uri) {
return $this->uri;
} else {
$id = $this->id;
$username = $this->profile->username;
$path = url(config('app.url')."/p/{$username}/{$id}");
return $path;
}
$id = $this->id;
$username = $this->profile->username;
$path = url(config('app.url')."/p/{$username}/{$id}");
return $path;
}
public function permalink($suffix = '/activity')
@ -207,6 +208,8 @@ class Status extends Model
$parent = $this->in_reply_to_id ?? $this->reblog_of_id;
if (!empty($parent)) {
return $this->findOrFail($parent);
} else {
return false;
}
}