kopia lustrzana https://github.com/pixelfed/pixelfed
				
				
				
			Update DiscoverController
							rodzic
							
								
									1351dc5ee8
								
							
						
					
					
						commit
						39f4b470b3
					
				| 
						 | 
					@ -65,27 +65,6 @@ class DiscoverController extends Controller
 | 
				
			||||||
      return view('discover.tags.category', compact('tag', 'posts'));
 | 
					      return view('discover.tags.category', compact('tag', 'posts'));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function showPersonal(Request $request)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      abort_if(!Auth::check(), 403);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      $profile = Auth::user()->profile;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      $tags = Cache::remember('profile-'.$profile->id.':hashtags', now()->addMinutes(15), function() use ($profile){
 | 
					 | 
				
			||||||
          return $profile->hashtags()->groupBy('hashtag_id')->inRandomOrder()->take(8)->get();
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
      $following = Cache::remember('profile:following:'.$profile->id, now()->addMinutes(60), function() use ($profile) {
 | 
					 | 
				
			||||||
          $res = Follower::whereProfileId($profile->id)->pluck('following_id');
 | 
					 | 
				
			||||||
          return $res->push($profile->id)->toArray();
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
      $posts = Cache::remember('profile-'.$profile->id.':hashtag-posts', now()->addMinutes(5), function() use ($profile, $following) {
 | 
					 | 
				
			||||||
          $posts = Status::whereScope('public')->withCount(['likes','comments'])->whereNotIn('profile_id', $following)->whereHas('media')->whereType('photo')->orderByDesc('created_at')->take(39)->get();
 | 
					 | 
				
			||||||
          $posts->post_count = Status::whereScope('public')->whereNotIn('profile_id', $following)->whereHas('media')->whereType('photo')->count();
 | 
					 | 
				
			||||||
          return $posts;
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
      return view('discover.personal', compact('posts', 'tags'));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function showLoops(Request $request)
 | 
					    public function showLoops(Request $request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if(config('exp.loops') != true) {
 | 
					      if(config('exp.loops') != true) {
 | 
				
			||||||
| 
						 | 
					@ -148,4 +127,10 @@ class DiscoverController extends Controller
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return $res;
 | 
					      return $res;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function profilesDirectory(Request $request)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      $profiles = Profile::whereNull('domain')->simplePaginate(48);
 | 
				
			||||||
 | 
					      return view('discover.profiles.home', compact('profiles'));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,6 +53,10 @@ class ImageUpdate implements ShouldQueue
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $path = storage_path('app/'.$media->media_path);
 | 
					        $path = storage_path('app/'.$media->media_path);
 | 
				
			||||||
        $thumb = storage_path('app/'.$media->thumbnail_path);
 | 
					        $thumb = storage_path('app/'.$media->thumbnail_path);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!is_file($path)) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (in_array($media->mime, $this->protectedMimes) == true) {
 | 
					        if (in_array($media->mime, $this->protectedMimes) == true) {
 | 
				
			||||||
            ImageOptimizer::optimize($thumb);
 | 
					            ImageOptimizer::optimize($thumb);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -298,7 +298,7 @@ class Inbox
 | 
				
			||||||
        $obj = $this->payload['object'];
 | 
					        $obj = $this->payload['object'];
 | 
				
			||||||
        $type = $this->payload['object']['type'];
 | 
					        $type = $this->payload['object']['type'];
 | 
				
			||||||
        $typeCheck = in_array($type, ['Person', 'Tombstone']);
 | 
					        $typeCheck = in_array($type, ['Person', 'Tombstone']);
 | 
				
			||||||
        if(!Helpers::validateUrl($actor) || !Helpers::validateUrl($obj) || !$typeCheck) {
 | 
					        if(!Helpers::validateUrl($actor) || !Helpers::validateUrl($obj['id']) || !$typeCheck) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if(parse_url($obj['id'], PHP_URL_HOST) !== parse_url($actor, PHP_URL_HOST)) {
 | 
					        if(parse_url($obj['id'], PHP_URL_HOST) !== parse_url($actor, PHP_URL_HOST)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue