refactor: rename variable

This commit is contained in:
Mustaque Ahmed
2025-10-14 16:59:48 +05:30
parent 528866b8b6
commit 931baeae14
4 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -1528,7 +1528,7 @@ return [
'array' => false,
],
[
'$id' => ID::custom('imageTransformations'),
'$id' => ID::custom('transformations'),
'type' => Database::VAR_BOOLEAN,
'signed' => true,
'size' => 0,
+6 -6
View File
@@ -314,7 +314,7 @@ App::put('/v1/storage/buckets/:bucketId')
$encryption ??= $bucket->getAttribute('encryption', true);
$antivirus ??= $bucket->getAttribute('antivirus', true);
$compression ??= $bucket->getAttribute('compression', Compression::NONE);
$transformations ??= $bucket->getAttribute('imageTransformations', true);
$transformations ??= $bucket->getAttribute('transformations', true);
// Map aggregate permissions into the multiple permissions they represent.
$permissions = Permission::aggregate($permissions);
@@ -326,7 +326,7 @@ App::put('/v1/storage/buckets/:bucketId')
->setAttribute('allowedFileExtensions', $allowedFileExtensions)
->setAttribute('fileSecurity', $fileSecurity)
->setAttribute('enabled', $enabled)
->setAttribute('imageTransformations', $transformations)
->setAttribute('transformations', $transformations)
->setAttribute('encryption', $encryption)
->setAttribute('compression', $compression)
->setAttribute('antivirus', $antivirus));
@@ -990,7 +990,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
}
// Check bucket-level transformations flag
$allowTransformations = $bucket->getAttribute('imageTransformations', true);
$allowTransformations = $bucket->getAttribute('transformations', true);
if (!$allowTransformations && !$isToken && !$isPrivilegedUser) {
// Transformations are disabled for this bucket
throw new Exception(Exception::STORAGE_TRANSFORMATIONS_DISABLED);
@@ -1124,7 +1124,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
// Update transformedAt only when image transformations are allowed
// Do not count Console/privileged requests — we only want to record
// transformedAt for actual API uses.
$allowTransformations = $bucket->getAttribute('imageTransformations', true);
$allowTransformations = $bucket->getAttribute('transformations', true);
$isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles());
if ($allowTransformations && !$isPrivilegedUser) {
$transformedAt = $file->getAttribute('transformedAt', '');
@@ -2034,7 +2034,7 @@ App::get('/v1/storage/:bucketId/usage')
'filesStorageTotal' => $usage[$metrics[1]]['total'],
'files' => $usage[$metrics[0]]['data'],
'storage' => $usage[$metrics[1]]['data'],
'transformations' => $usage[$metrics[2]]['data'],
'transformationsTotal' => $usage[$metrics[2]]['total'],
'imageTransformations' => $usage[$metrics[2]]['data'],
'imageTransformationsTotal' => $usage[$metrics[2]]['total'],
]), Response::MODEL_USAGE_BUCKETS);
});
+3 -3
View File
@@ -557,7 +557,7 @@ App::init()
if ($useCache) {
$route = $utopia->match($request);
$isImageTransformation = $route->getPath() === '/v1/storage/buckets/:bucketId/files/:fileId/preview';
$isPlanTransformationsDisabled = isset($plan['imageTransformations']) && $plan['imageTransformations'] === -1 && !Auth::isPrivilegedUser(Authorization::getRoles());
$isPlanTransformationsDisabled = isset($plan['transformations']) && $plan['transformations'] === -1 && !Auth::isPrivilegedUser(Authorization::getRoles());
$key = $request->cacheIdentifier();
@@ -580,7 +580,7 @@ App::init()
$bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId));
// Check if bucket explicitly disables transformations
$isBucketTransformationsDisabled = !$bucket->getAttribute('imageTransformations', true);
$isBucketTransformationsDisabled = !$bucket->getAttribute('transformations', true);
// Combined check: disabled if either plan or bucket disables it
$isTransformationsBlocked = $isPlanTransformationsDisabled || $isBucketTransformationsDisabled;
@@ -622,7 +622,7 @@ App::init()
throw new Exception(Exception::STORAGE_FILE_NOT_FOUND);
}
// Update transformedAt only when bucket and plan allow transformations
$allowTransformations = $bucket->getAttribute('imageTransformations', true);
$allowTransformations = $bucket->getAttribute('transformations', true);
if ($allowTransformations) {
$transformedAt = $file->getAttribute('transformedAt', '');
if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $transformedAt) {
+2 -2
View File
@@ -272,7 +272,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg
'encryption' => true,
'antivirus' => true,
'fileSecurity' => true,
'imageTransformations' => true,
'transformations' => true,
'$permissions' => [
Permission::create(Role::any()),
Permission::read(Role::any()),
@@ -326,7 +326,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg
'encryption' => false,
'antivirus' => false,
'fileSecurity' => true,
'imageTransformations' => true,
'transformations' => true,
'$permissions' => [],
'search' => 'buckets Screenshots',
])));