Browse Source

Update PublicApiController

Daniel Supernault 6 years ago
parent
commit
dbaf903d68
1 changed files with 5 additions and 5 deletions
  1. 5 5
      app/Http/Controllers/PublicApiController.php

+ 5 - 5
app/Http/Controllers/PublicApiController.php

@@ -110,7 +110,7 @@ class PublicApiController extends Controller
         ]);
         $limit = $request->limit ?? 10;
         $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
-        $status = Status::whereProfileId($profile->id)->findOrFail($postId);
+        $status = Status::whereProfileId($profile->id)->whereCommentsDisabled(false)->findOrFail($postId);
         $this->scopeCheck($profile, $status);
         if($request->filled('min_id') || $request->filled('max_id')) {
             if($request->filled('min_id')) {
@@ -578,9 +578,9 @@ class PublicApiController extends Controller
                     $following = Follower::whereProfileId($pid)->pluck('following_id');
                     return $following->push($pid)->toArray();
                 });
-                $visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : ['public'];
+                $visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
             } else {
-                $visibility = ['public'];
+                $visibility = ['public', 'unlisted'];
             }
         }
 
@@ -606,8 +606,8 @@ class PublicApiController extends Controller
           ->whereLocal(true)
           ->whereNull('uri')
           ->where('id', $dir, $id)
-          ->whereIn('visibility',$visibility)
-          ->orderBy('created_at', 'desc')
+          ->whereIn('visibility', $visibility)
+          ->latest()
           ->limit($limit)
           ->get();