Merge pull request #1670 from pixelfed/staging

Update web routes
This commit is contained in:
daniel 2019-09-06 23:26:41 -06:00 committed by GitHub
commit 2785899317
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 23 deletions

View file

@ -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'));
}
} }

View file

@ -54,6 +54,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);
ImageOptimizer::optimize($path); ImageOptimizer::optimize($path);

View file

@ -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)) {

View file

@ -68,7 +68,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('/home', 'HomeController@index')->name('home'); Route::get('/home', 'HomeController@index')->name('home');
Route::get('discover/c/{slug}', 'DiscoverController@showCategory'); Route::get('discover/c/{slug}', 'DiscoverController@showCategory');
Route::get('discover/personal', 'DiscoverController@showPersonal'); Route::redirect('discover/personal', '/discover');
Route::get('discover', 'DiscoverController@home')->name('discover'); Route::get('discover', 'DiscoverController@home')->name('discover');
Route::get('discover/loops', 'DiscoverController@showLoops'); Route::get('discover/loops', 'DiscoverController@showLoops');