From 40478f258aa60c8672d5e48aec347cd88cd07ba6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 12 Mar 2024 02:05:22 -0600 Subject: [PATCH] Update landing settings, use config_cache --- app/Http/Controllers/LandingController.php | 39 +++++++++++----------- app/Services/LandingService.php | 4 +-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index 5f9f0bba1..f90d84bc2 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -2,44 +2,43 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use App\Profile; -use App\Services\AccountService; use App\Http\Resources\DirectoryProfile; +use App\Profile; +use Illuminate\Http\Request; class LandingController extends Controller { public function directoryRedirect(Request $request) { - if($request->user()) { - return redirect('/'); - } + if ($request->user()) { + return redirect('/'); + } - abort_if(config_cache('instance.landing.show_directory') == false, 404); + abort_if((bool) config_cache('instance.landing.show_directory') == false, 404); - return view('site.index'); + return view('site.index'); } public function exploreRedirect(Request $request) { - if($request->user()) { - return redirect('/'); - } + if ($request->user()) { + return redirect('/'); + } - abort_if(config_cache('instance.landing.show_explore') == false, 404); + abort_if((bool) config_cache('instance.landing.show_explore') == false, 404); - return view('site.index'); + return view('site.index'); } public function getDirectoryApi(Request $request) { - abort_if(config_cache('instance.landing.show_directory') == false, 404); + abort_if((bool) config_cache('instance.landing.show_directory') == false, 404); - return DirectoryProfile::collection( - Profile::whereNull('domain') - ->whereIsSuggestable(true) - ->orderByDesc('updated_at') - ->cursorPaginate(20) - ); + return DirectoryProfile::collection( + Profile::whereNull('domain') + ->whereIsSuggestable(true) + ->orderByDesc('updated_at') + ->cursorPaginate(20) + ); } } diff --git a/app/Services/LandingService.php b/app/Services/LandingService.php index 20759ecf4..213e63910 100644 --- a/app/Services/LandingService.php +++ b/app/Services/LandingService.php @@ -53,8 +53,8 @@ class LandingService 'name' => config_cache('app.name'), 'url' => config_cache('app.url'), 'domain' => config('pixelfed.domain.app'), - 'show_directory' => config_cache('instance.landing.show_directory'), - 'show_explore_feed' => config_cache('instance.landing.show_explore'), + 'show_directory' => (bool) config_cache('instance.landing.show_directory'), + 'show_explore_feed' => (bool) config_cache('instance.landing.show_explore'), 'open_registration' => (bool) $openReg, 'curated_onboarding' => (bool) config_cache('instance.curated_registration.enabled'), 'version' => config('pixelfed.version'),