diff --git a/app/Http/Controllers/AppFunctionsController.php b/app/Http/Controllers/AppFunctionsController.php index 763325ab..79bf8d60 100644 --- a/app/Http/Controllers/AppFunctionsController.php +++ b/app/Http/Controllers/AppFunctionsController.php @@ -60,45 +60,28 @@ class AppFunctionsController extends Controller // Try to connect to database \DB::getPdo(); - // Check settings table - $settings_table = Schema::hasTable('settings'); - $users_table = Schema::hasTable('users'); + // Get setup status + $setup_status = $this->get_setup_status(); - // If settings table don't exist, then run migrations - if ($users_table && !$settings_table) { - Artisan::call('migrate', [ - '--force' => true - ]); - } - - // Get settings - $upgraded = Setting::where('name', 'latest_upgrade')->first(); - - // Get connection string - if ($upgraded && $upgraded->value !== '1.7') { - $connection = 'quiet-update'; - } else if (!$upgraded) { - $connection = 'quiet-update'; - } else { - $connection = $this->get_setup_status(); - } + // Get app pages + $pages = Page::all(); // Get all settings - $settings = Setting::all(); - - // Get legal pages - $legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy']) - ->get(['visibility', 'title', 'slug']); + $settings = json_decode( + Setting::all() + ->pluck('value', 'name') + ->toJson() + ); } catch (PDOException $e) { - $connection = 'setup-database'; - $settings = null; + + $setup_status = 'setup-database'; } return view("index") - ->with('settings', $settings ? json_decode($settings->pluck('value', 'name')->toJson()) : null) - ->with('legal', isset($legal) ? $legal : null) - ->with('installation', $connection); + ->with('settings', $settings ?? null) + ->with('legal', $pages ?? null) + ->with('installation', $setup_status); } /** @@ -172,9 +155,7 @@ class AppFunctionsController extends Controller { $setup_success = get_setting('setup_wizard_success'); - $connection = boolval($setup_success) ? 'setup-done' : 'setup-disclaimer'; - - return $connection; + return boolval($setup_success) ? 'setup-done' : 'setup-disclaimer'; } /** diff --git a/composer.json b/composer.json index 181d2ba4..30168931 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "league/flysystem-aws-s3-v3": "^1.0", "league/flysystem-cached-adapter": "^1.0", "madnest/madzipper": "^1.1", - "teamtnt/laravel-scout-tntsearch-driver": "^11.1" + "teamtnt/laravel-scout-tntsearch-driver": "^11.1", + "ext-json": "*" }, "require-dev": { "ext-json": "*", diff --git a/routes/share.php b/routes/share.php index 521321ce..6de4d066 100644 --- a/routes/share.php +++ b/routes/share.php @@ -21,8 +21,8 @@ Route::group(['prefix' => 'zip'], function () { // Browse share content Route::group(['prefix' => 'browse'], function () { - Route::get('/folders/{id}/public/{token}', [FileSharingController::class, 'get_public_folders']); Route::get('/navigation/public/{token}', [FileSharingController::class, 'get_public_navigation_tree']); + Route::get('/folders/{id}/public/{token}', [FileSharingController::class, 'get_public_folders']); Route::post('/shared/authenticate/{token}', [FileSharingController::class, 'authenticate']); Route::get('/search/public/{token}', [FileSharingController::class, 'search_public']); Route::get('/files/{token}/public', [FileSharingController::class, 'file_public']); diff --git a/tests/Feature/App/AppTest.php b/tests/Feature/App/AppTest.php new file mode 100644 index 00000000..4ed837c5 --- /dev/null +++ b/tests/Feature/App/AppTest.php @@ -0,0 +1,33 @@ +setup = app()->make(SetupService::class); + } + + /** + * @test + */ + public function it_get_index_page() + { + $this->setup->seed_default_pages(); + + $this->setup->seed_default_settings('Extended'); + + $this->get('/') + ->assertStatus(200); + } +} diff --git a/tests/Feature/System/SchedulerTest.php b/tests/Feature/App/SchedulerTest.php similarity index 100% rename from tests/Feature/System/SchedulerTest.php rename to tests/Feature/App/SchedulerTest.php