Update admin settings

This commit is contained in:
Daniel Supernault 2021-05-19 02:15:37 -06:00
parent 24e77f647d
commit 29947e157c
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 12 additions and 7 deletions

View File

@ -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;

View File

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