1
0
Fork 0

Update config() to config_cache()

This commit is contained in:
Daniel Supernault 2021-05-10 23:23:09 -06:00
parent c0e693cc73
commit 27b722e7a7
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
5 changed files with 158 additions and 158 deletions

View File

@ -967,7 +967,7 @@ class ApiV1Controller extends Controller
'short_description' => 'Pixelfed - Photo sharing for everyone', 'short_description' => 'Pixelfed - Photo sharing for everyone',
'languages' => ['en'], 'languages' => ['en'],
'max_toot_chars' => (int) config('pixelfed.max_caption_length'), 'max_toot_chars' => (int) config('pixelfed.max_caption_length'),
'registrations' => config('pixelfed.open_registration'), 'registrations' => config_cache('pixelfed.open_registration'),
'stats' => [ 'stats' => [
'user_count' => 0, 'user_count' => 0,
'status_count' => 0, 'status_count' => 0,

View File

@ -154,7 +154,7 @@ class RegisterController extends Controller
*/ */
public function showRegistrationForm() public function showRegistrationForm()
{ {
if(config('pixelfed.open_registration')) { if(config_cache('pixelfed.open_registration')) {
$limit = config('pixelfed.max_users'); $limit = config('pixelfed.max_users');
if($limit) { if($limit) {
abort_if($limit <= User::count(), 404); abort_if($limit <= User::count(), 404);
@ -175,12 +175,12 @@ class RegisterController extends Controller
*/ */
public function register(Request $request) public function register(Request $request)
{ {
abort_if(config('pixelfed.open_registration') == false, 400); abort_if(config_cache('pixelfed.open_registration') == false, 400);
$count = User::count(); $count = User::count();
$limit = config('pixelfed.max_users'); $limit = config('pixelfed.max_users');
if(false == config('pixelfed.open_registration') || $limit && $limit <= $count) { if(false == config_cache('pixelfed.open_registration') || $limit && $limit <= $count) {
return abort(403); return abort(403);
} }

View File

@ -10,7 +10,7 @@ class Config {
public static function get() { public static function get() {
return Cache::remember('api:site:configuration:_v0.2', now()->addMinutes(5), function() { return Cache::remember('api:site:configuration:_v0.2', now()->addMinutes(5), function() {
return [ return [
'open_registration' => config('pixelfed.open_registration'), 'open_registration' => (bool) config_cache('pixelfed.open_registration'),
'uploader' => [ 'uploader' => [
'max_photo_size' => config('pixelfed.max_photo_size'), 'max_photo_size' => config('pixelfed.max_photo_size'),
'max_caption_length' => config('pixelfed.max_caption_length'), 'max_caption_length' => config('pixelfed.max_caption_length'),

View File

@ -70,7 +70,7 @@ class Nodeinfo {
'version' => '2.0', 'version' => '2.0',
]; ];
}); });
$res['openRegistrations'] = config('pixelfed.open_registration'); $res['openRegistrations'] = (bool) config_cache('pixelfed.open_registration');
return $res; return $res;
} }

View File

@ -22,7 +22,7 @@
{{ __('Login') }} {{ __('Login') }}
</a> </a>
</li> </li>
@if(config('pixelfed.open_registration') && config('instance.restricted.enabled') == false) @if(config_cache('pixelfed.open_registration') && config('instance.restricted.enabled') == false)
<li> <li>
<a class="ml-3 nav-link font-weight-bold text-dark" href="{{ route('register') }}" title="Register"> <a class="ml-3 nav-link font-weight-bold text-dark" href="{{ route('register') }}" title="Register">
{{ __('Register') }} {{ __('Register') }}