浏览代码

Merge pull request #4154 from pixelfed/staging

Staging
daniel 2 年之前
父节点
当前提交
88ddf55f6a
共有 3 个文件被更改,包括 21 次插入4 次删除
  1. 17 1
      app/Http/Controllers/Api/ApiV1Controller.php
  2. 2 2
      app/Http/Controllers/PublicApiController.php
  3. 2 1
      app/Media.php

+ 17 - 1
app/Http/Controllers/Api/ApiV1Controller.php

@@ -1972,6 +1972,11 @@ class ApiV1Controller extends Controller
 			return $following->push($pid)->toArray();
 			return $following->push($pid)->toArray();
 		});
 		});
 
 
+		$includeReplies = false;
+		if(config('exp.top')) {
+            $includeReplies = (bool) Redis::zscore('pf:tl:replies', $pid);
+        }
+
 		if(config('instance.timeline.home.cached') && (!$min && !$max)) {
 		if(config('instance.timeline.home.cached') && (!$min && !$max)) {
             $ttl = config('instance.timeline.home.cache_ttl');
             $ttl = config('instance.timeline.home.cache_ttl');
             $res = Cache::remember(
             $res = Cache::remember(
@@ -1980,7 +1985,8 @@ class ApiV1Controller extends Controller
                 function() use(
                 function() use(
                 $following,
                 $following,
                 $limit,
                 $limit,
-                $pid
+                $pid,
+                $includeReplies
                 ) {
                 ) {
                 return Status::select(
                 return Status::select(
                     'id',
                     'id',
@@ -2002,6 +2008,11 @@ class ApiV1Controller extends Controller
                     'created_at',
                     'created_at',
                     'updated_at'
                     'updated_at'
                   )
                   )
+                  ->when($includeReplies, function($q, $includeReplies) {
+                    return $q;
+                  }, function($q, $includeReplies) {
+                    return $q->whereNull('in_reply_to_id');
+                  })
                   ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
                   ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
                   ->whereIn('profile_id', $following)
                   ->whereIn('profile_id', $following)
                   ->whereIn('visibility',['public', 'unlisted', 'private'])
                   ->whereIn('visibility',['public', 'unlisted', 'private'])
@@ -2053,6 +2064,11 @@ class ApiV1Controller extends Controller
 			)
 			)
 			->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
 			->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
 			->where('id', $dir, $id)
 			->where('id', $dir, $id)
+            ->when($includeReplies, function($q, $includeReplies) {
+                return $q;
+            }, function($q, $includeReplies) {
+                return $q->whereNull('in_reply_to_id');
+            })
 			->whereIn('profile_id', $following)
 			->whereIn('profile_id', $following)
 			->whereIn('visibility',['public', 'unlisted', 'private'])
 			->whereIn('visibility',['public', 'unlisted', 'private'])
 			->latest()
 			->latest()

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

@@ -472,10 +472,10 @@ class PublicApiController extends Controller
         // $types = ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album', 'text'];
         // $types = ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album', 'text'];
 
 
         $textOnlyReplies = false;
         $textOnlyReplies = false;
+        $textOnlyReplies = (bool) Redis::zscore('pf:tl:replies', $pid);
 
 
         if(config('exp.top')) {
         if(config('exp.top')) {
             $textOnlyPosts = (bool) Redis::zscore('pf:tl:top', $pid);
             $textOnlyPosts = (bool) Redis::zscore('pf:tl:top', $pid);
-            $textOnlyReplies = (bool) Redis::zscore('pf:tl:replies', $pid);
 
 
             if($textOnlyPosts) {
             if($textOnlyPosts) {
                 array_push($types, 'text');
                 array_push($types, 'text');
@@ -587,7 +587,7 @@ class PublicApiController extends Controller
                         'updated_at'
                         'updated_at'
                       )
                       )
                       ->whereIn('type', $types)
                       ->whereIn('type', $types)
-                      ->when($textOnlyReplies != true, function($q, $textOnlyReplies) {
+                      ->when(!$textOnlyReplies, function($q, $textOnlyReplies) {
                         return $q->whereNull('in_reply_to_id');
                         return $q->whereNull('in_reply_to_id');
                       })
                       })
                       ->where('id', $dir, $id)
                       ->where('id', $dir, $id)

+ 2 - 1
app/Media.php

@@ -38,7 +38,8 @@ class Media extends Model
     public function url()
     public function url()
     {
     {
         if($this->cdn_url) {
         if($this->cdn_url) {
-            return Storage::disk(config('filesystems.cloud'))->url($this->media_path);
+            // return Storage::disk(config('filesystems.cloud'))->url($this->media_path);
+            return $this->cdn_url;
         }
         }
 
 
         if($this->remote_media && $this->remote_url) {
         if($this->remote_media && $this->remote_url) {