From 29947e157c736dd30b296d1bc5cac5cc73f8d55f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 19 May 2021 02:15:37 -0600 Subject: [PATCH] Update admin settings --- .../Admin/AdminSettingsController.php | 3 ++- app/Services/ConfigCacheService.php | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminSettingsController.php b/app/Http/Controllers/Admin/AdminSettingsController.php index 055fec353..f6fce8a52 100644 --- a/app/Http/Controllers/Admin/AdminSettingsController.php +++ b/app/Http/Controllers/Admin/AdminSettingsController.php @@ -5,7 +5,8 @@ namespace App\Http\Controllers\Admin; use Artisan, Cache, DB; use Illuminate\Http\Request; use Carbon\Carbon; -use App\{Comment, InstanceActor, Like, Media, Page, Profile, Report, Status, User}; +use App\{Comment, Like, Media, Page, Profile, Report, Status, User}; +use App\Models\InstanceActor; use App\Http\Controllers\Controller; use App\Util\Lexer\PrettyNumber; use App\Models\ConfigCache; diff --git a/app/Services/ConfigCacheService.php b/app/Services/ConfigCacheService.php index 7c1f0c9ab..18ccab050 100644 --- a/app/Services/ConfigCacheService.php +++ b/app/Services/ConfigCacheService.php @@ -8,12 +8,13 @@ use App\Models\ConfigCache as ConfigCacheModel; class ConfigCacheService { - const CACHE_KEY = 'config_cache:_key:'; + const CACHE_KEY = 'config_cache:_v0-key:'; public static function get($key) { - $cacheKey = "config_cache:_key:{$key}"; + $cacheKey = self::CACHE_KEY . $key; $ttl = now()->addHours(12); + return Cache::remember($cacheKey, $ttl, function() use($key) { $allowed = [ @@ -29,8 +30,8 @@ class ConfigCacheService 'pixelfed.open_registration', 'federation.activitypub.enabled', - 'pixelfed.oauth_enabled', 'instance.stories.enabled', + 'pixelfed.oauth_enabled', 'pixelfed.import.instagram.enabled', 'pixelfed.bouncer.enabled', @@ -41,7 +42,10 @@ class ConfigCacheService 'uikit.custom.css', 'uikit.custom.js', 'uikit.show_custom.css', - 'uikit.show_custom.js' + 'uikit.show_custom.js', + 'about.title', + + 'pixelfed.cloud_storage' ]; if(!config('instance.enable_cc')) { @@ -79,7 +83,7 @@ class ConfigCacheService if($exists) { $exists->v = $val; $exists->save(); - Cache::forget(self::CACHE_KEY . $key); + Cache::put(self::CACHE_KEY . $key, $val, now()->addHours(12)); return self::get($key); } @@ -88,7 +92,7 @@ class ConfigCacheService $cc->v = $val; $cc->save(); - Cache::forget(self::CACHE_KEY . $key); + Cache::put(self::CACHE_KEY . $key, $val, now()->addHours(12)); return self::get($key); }