浏览代码

Update PublicApiController

Daniel Supernault 6 年之前
父节点
当前提交
dbaf903d68
共有 1 个文件被更改,包括 5 次插入5 次删除
  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();