Update user_filters, use config_cache

This commit is contained in:
Daniel Supernault 2024-03-14 00:06:33 -06:00
parent 949e99798e
commit 6ce513f8c3
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
4 changed files with 8 additions and 5 deletions

View file

@ -157,7 +157,7 @@ class AccountController extends Controller
$pid = $request->user()->profile_id;
$count = UserFilterService::muteCount($pid);
$maxLimit = intval(config('instance.user_filters.max_user_mutes'));
$maxLimit = (int) config_cache('instance.user_filters.max_user_mutes');
abort_if($count >= $maxLimit, 422, self::FILTER_LIMIT_MUTE_TEXT . $maxLimit . ' accounts');
if($count == 0) {
$filterCount = UserFilter::whereUserId($pid)->count();
@ -260,7 +260,7 @@ class AccountController extends Controller
]);
$pid = $request->user()->profile_id;
$count = UserFilterService::blockCount($pid);
$maxLimit = intval(config('instance.user_filters.max_user_blocks'));
$maxLimit = (int) config_cache('instance.user_filters.max_user_blocks');
abort_if($count >= $maxLimit, 422, self::FILTER_LIMIT_BLOCK_TEXT . $maxLimit . ' accounts');
if($count == 0) {
$filterCount = UserFilter::whereUserId($pid)->whereFilterType('block')->count();

View file

@ -1103,7 +1103,7 @@ class ApiV1Controller extends Controller
}
$count = UserFilterService::blockCount($pid);
$maxLimit = intval(config('instance.user_filters.max_user_blocks'));
$maxLimit = (int) config_cache('instance.user_filters.max_user_blocks');
if ($count == 0) {
$filterCount = UserFilter::whereUserId($pid)
->whereFilterType('block')
@ -2145,7 +2145,7 @@ class ApiV1Controller extends Controller
}
$count = UserFilterService::muteCount($pid);
$maxLimit = intval(config('instance.user_filters.max_user_mutes'));
$maxLimit = (int) config_cache('instance.user_filters.max_user_mutes');
if ($count == 0) {
$filterCount = UserFilter::whereUserId($pid)
->whereFilterType('mute')

View file

@ -72,7 +72,7 @@ class DomainBlockController extends Controller
abort_if(config_cache('pixelfed.domain.app') == $domain, 400, 'Cannot ban your own server');
$existingCount = UserDomainBlock::whereProfileId($pid)->count();
$maxLimit = config('instance.user_filters.max_domain_blocks');
$maxLimit = (int) config_cache('instance.user_filters.max_domain_blocks');
$errorMsg = __('profile.block.domain.max', ['max' => $maxLimit]);
abort_if($existingCount >= $maxLimit, 400, $errorMsg);

View file

@ -103,6 +103,9 @@ class ConfigCacheService
'pixelfed.optimize_video',
'pixelfed.max_collection_length',
'media.delete_local_after_cloud',
'instance.user_filters.max_user_blocks',
'instance.user_filters.max_user_mutes',
'instance.user_filters.max_domain_blocks',
// 'system.user_mode'
];