Browse Source

Update Status model

Daniel Supernault 6 years ago
parent
commit
402408e48c
1 changed files with 8 additions and 5 deletions
  1. 8 5
      app/Status.php

+ 8 - 5
app/Status.php

@@ -87,7 +87,7 @@ class Status extends Model
         return Cache::remember('status:thumb:'.$this->id, now()->addMinutes(15), function() use ($showNsfw) {
         return Cache::remember('status:thumb:'.$this->id, now()->addMinutes(15), function() use ($showNsfw) {
             $type = $this->type ?? $this->setType();
             $type = $this->type ?? $this->setType();
             $is_nsfw = !$showNsfw ? $this->is_nsfw : false;
             $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'));
                 return url(Storage::url('public/no-preview.png'));
             }
             }
 
 
@@ -99,11 +99,12 @@ class Status extends Model
     {
     {
         if($this->uri) {
         if($this->uri) {
             return $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')
     public function permalink($suffix = '/activity')
@@ -207,6 +208,8 @@ class Status extends Model
         $parent = $this->in_reply_to_id ?? $this->reblog_of_id;
         $parent = $this->in_reply_to_id ?? $this->reblog_of_id;
         if (!empty($parent)) {
         if (!empty($parent)) {
             return $this->findOrFail($parent);
             return $this->findOrFail($parent);
+        } else {
+            return false;
         }
         }
     }
     }