diff --git a/.circleci/config.yml b/.circleci/config.yml index ca2b7b2d..4725eb32 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,10 +41,10 @@ jobs: - vendor - run: cp .env.testing .env + - run: php artisan config:cache - run: php artisan route:clear - run: php artisan storage:link - run: php artisan key:generate - - run: php artisan config:clear # run tests with phpunit or codecept - run: ./vendor/bin/phpunit diff --git a/.env.testing b/.env.testing index 94cc0d13..258d8d74 100644 --- a/.env.testing +++ b/.env.testing @@ -65,3 +65,5 @@ CS_UNLISTED_DOMAINS='example.org,example.net,example.com' ## Optional #HORIZON_DARKMODE=false # Horizon theme darkmode #HORIZON_EMBED=false # Single Docker Container mode + +ENABLE_CONFIG_CACHE=false diff --git a/CHANGELOG.md b/CHANGELOG.md index a6d6a10a..033727ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,18 @@ ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.6...dev) +### Added +- Added store remote media on S3 config setting, disabled by default ([51768083](https://github.com/pixelfed/pixelfed/commit/51768083)) + ### Updates - Update admin dashboard, fix search and dropdown menu ([dac0d083](https://github.com/pixelfed/pixelfed/commit/dac0d083)) - Update sudo mode view, fix trusted device checkbox ([8ef900bf](https://github.com/pixelfed/pixelfed/commit/8ef900bf)) - Update SearchApiV2Service, improve postgres support ([666e5732](https://github.com/pixelfed/pixelfed/commit/666e5732)) - Update StoryController, show active self stories on home timeline ([633351f6](https://github.com/pixelfed/pixelfed/commit/633351f6)) +- Update ApiV1Controller, fix trending accounts format. Closes #4356 ([37bd2ee5](https://github.com/pixelfed/pixelfed/commit/37bd2ee5)) +- Update instance config, enable config cache by default ([970f77b0](https://github.com/pixelfed/pixelfed/commit/970f77b0)) +- Update Admin Dashboard, allow admins to designate an admin account for the landing page and instance api endpoint ([6ea2bdc7](https://github.com/pixelfed/pixelfed/commit/6ea2bdc7)) +- Update config, enable oauth by default ([6a2e9e8f](https://github.com/pixelfed/pixelfed/commit/6a2e9e8f)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.6 (2023-05-03)](https://github.com/pixelfed/pixelfed/compare/v0.11.5...v0.11.6) diff --git a/app/Http/Controllers/Admin/AdminSettingsController.php b/app/Http/Controllers/Admin/AdminSettingsController.php index d5187082..9d9c3dfb 100644 --- a/app/Http/Controllers/Admin/AdminSettingsController.php +++ b/app/Http/Controllers/Admin/AdminSettingsController.php @@ -10,8 +10,10 @@ use App\Models\InstanceActor; use App\Http\Controllers\Controller; use App\Util\Lexer\PrettyNumber; use App\Models\ConfigCache; +use App\Services\AccountService; use App\Services\ConfigCacheService; use App\Util\Site\Config; +use Illuminate\Support\Str; trait AdminSettingsController { @@ -28,6 +30,9 @@ trait AdminSettingsController $mp4 = in_array('video/mp4', $types); $webp = in_array('image/webp', $types); + $availableAdmins = User::whereIsAdmin(true)->get(); + $currentAdmin = config_cache('instance.admin.pid') ? AccountService::get(config_cache('instance.admin.pid'), true) : null; + // $system = [ // 'permissions' => is_writable(base_path('storage')) && is_writable(base_path('bootstrap')), // 'max_upload_size' => ini_get('post_max_size'), @@ -45,6 +50,8 @@ trait AdminSettingsController 'cloud_storage', 'cloud_disk', 'cloud_ready', + 'availableAdmins', + 'currentAdmin' // 'system' )); } @@ -63,8 +70,14 @@ trait AdminSettingsController 'type_gif' => 'nullable', 'type_mp4' => 'nullable', 'type_webp' => 'nullable', + 'admin_account_id' => 'nullable', ]); + if($request->filled('admin_account_id')) { + ConfigCacheService::put('instance.admin.pid', $request->admin_account_id); + Cache::forget('api:v1:instance-data:contact'); + Cache::forget('api:v1:instance-data-response-v1'); + } if($request->filled('rule_delete')) { $index = (int) $request->input('rule_delete'); $rules = ConfigCacheService::get('app.rules'); @@ -75,8 +88,8 @@ trait AdminSettingsController unset($json[$index]); $json = json_encode(array_values($json)); ConfigCacheService::put('app.rules', $json); - Cache::forget('api:v1:instance-data:rules'); - Cache::forget('api:v1:instance-data-response-v1'); + Cache::forget('api:v1:instance-data:rules'); + Cache::forget('api:v1:instance-data-response-v1'); return 200; } @@ -124,8 +137,8 @@ trait AdminSettingsController if($cc && $cc->v != $val) { ConfigCacheService::put($value, $val); } else if(!empty($val)) { - ConfigCacheService::put($value, $val); - } + ConfigCacheService::put($value, $val); + } } $bools = [ @@ -141,8 +154,8 @@ trait AdminSettingsController 'show_custom_js' => 'uikit.show_custom.js', 'cloud_storage' => 'pixelfed.cloud_storage', 'account_autofollow' => 'account.autofollow', - 'show_directory' => 'landing.show_directory', - 'show_explore_feed' => 'landing.show_explore_feed', + 'show_directory' => 'instance.landing.show_directory', + 'show_explore_feed' => 'instance.landing.show_explore', ]; foreach ($bools as $key => $value) { diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index e6f60d06..1ba73ae8 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1554,6 +1554,9 @@ class ApiV1Controller extends Controller { $res = Cache::remember('api:v1:instance-data-response-v1', 1800, function () { $contact = Cache::remember('api:v1:instance-data:contact', 604800, function () { + if(config_cache('instance.admin.pid')) { + return AccountService::getMastodon(config_cache('instance.admin.pid'), true); + } $admin = User::whereIsAdmin(true)->first(); return $admin && isset($admin->profile_id) ? AccountService::getMastodon($admin->profile_id, true) : diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index 1472a78e..5f9f0bba 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -15,7 +15,7 @@ class LandingController extends Controller return redirect('/'); } - abort_if(config('instance.landing.show_directory') == false, 404); + abort_if(config_cache('instance.landing.show_directory') == false, 404); return view('site.index'); } @@ -26,14 +26,14 @@ class LandingController extends Controller return redirect('/'); } - abort_if(config('instance.landing.show_explore') == false, 404); + abort_if(config_cache('instance.landing.show_explore') == false, 404); return view('site.index'); } public function getDirectoryApi(Request $request) { - abort_if(config('instance.landing.show_directory') == false, 404); + abort_if(config_cache('instance.landing.show_directory') == false, 404); return DirectoryProfile::collection( Profile::whereNull('domain') diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 9c6adc32..0ec8c189 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -24,7 +24,7 @@ class AuthServiceProvider extends ServiceProvider */ public function boot() { - if(config_cache('pixelfed.oauth_enabled') == true) { + if(config('app.env') === 'production' && config('pixelfed.oauth_enabled') == true) { Passport::tokensExpireIn(now()->addDays(config('instance.oauth.token_expiration', 356))); Passport::refreshTokensExpireIn(now()->addDays(config('instance.oauth.refresh_expiration', 400))); Passport::enableImplicitGrant(); diff --git a/app/Services/ConfigCacheService.php b/app/Services/ConfigCacheService.php index 4ffa8da6..23b76248 100644 --- a/app/Services/ConfigCacheService.php +++ b/app/Services/ConfigCacheService.php @@ -65,6 +65,10 @@ class ConfigCacheService 'pixelfed.directory.latest_response', 'pixelfed.directory.is_synced', 'pixelfed.directory.testimonials', + + 'instance.landing.show_directory', + 'instance.landing.show_explore', + 'instance.admin.pid', // 'system.user_mode' ]; diff --git a/app/Services/LandingService.php b/app/Services/LandingService.php index f0af2ddf..2a5acda0 100644 --- a/app/Services/LandingService.php +++ b/app/Services/LandingService.php @@ -30,6 +30,9 @@ class LandingService }); $contactAccount = Cache::remember('api:v1:instance-data:contact', 604800, function () { + if(config_cache('instance.admin.pid')) { + return AccountService::getMastodon(config_cache('instance.admin.pid'), true); + } $admin = User::whereIsAdmin(true)->first(); return $admin && isset($admin->profile_id) ? AccountService::getMastodon($admin->profile_id, true) : @@ -53,8 +56,8 @@ class LandingService 'name' => config_cache('app.name'), 'url' => config_cache('app.url'), 'domain' => config('pixelfed.domain.app'), - 'show_directory' => config('instance.landing.show_directory'), - 'show_explore_feed' => config('instance.landing.show_explore'), + 'show_directory' => config_cache('instance.landing.show_directory'), + 'show_explore_feed' => config_cache('instance.landing.show_explore'), 'open_registration' => config_cache('pixelfed.open_registration') == 1, 'version' => config('pixelfed.version'), 'about' => [ diff --git a/config/instance.php b/config/instance.php index 7ba66c85..9d10e210 100644 --- a/config/instance.php +++ b/config/instance.php @@ -89,7 +89,7 @@ return [ ] ], - 'enable_cc' => env('ENABLE_CONFIG_CACHE', false), + 'enable_cc' => env('ENABLE_CONFIG_CACHE', true), 'has_legal_notice' => env('INSTANCE_LEGAL_NOTICE', false), diff --git a/config/pixelfed.php b/config/pixelfed.php index 4faded26..19db9e61 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -255,7 +255,7 @@ return [ ] ], - 'oauth_enabled' => env('OAUTH_ENABLED', false), + 'oauth_enabled' => env('OAUTH_ENABLED', true), 'bouncer' => [ 'enabled' => env('PF_BOUNCER_ENABLED', false), diff --git a/resources/views/admin/settings/home.blade.php b/resources/views/admin/settings/home.blade.php index 89f860b0..7635ac61 100644 --- a/resources/views/admin/settings/home.blade.php +++ b/resources/views/admin/settings/home.blade.php @@ -148,36 +148,43 @@
The instance name. Change in Brand section.
+Configure your landing page
Description of instance used on about section. Change in Brand section.
-Discovery
To disable the Directory, set INSTANCE_LANDING_SHOW_DIRECTORY=false
in .env
To disable the Explore feed, set INSTANCE_LANDING_SHOW_EXPLORE=false
in .env
Admin Account
+ +