refactor: address coderabbitai comments

This commit is contained in:
Mustaque Ahmed
2025-10-14 11:55:50 +05:30
parent 52ee23748d
commit 12abcb5806
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -991,7 +991,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
// Check bucket-level image transformations flag
$allowImageTransformations = $bucket->getAttribute('imageTransformations', true);
if (!$allowImageTransformations && !$isToken) {
if (!$allowImageTransformations && !$isToken && !$isPrivilegedUser) {
// Image transformations are disabled for this bucket
throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED);
}
+5 -3
View File
@@ -589,8 +589,8 @@ App::init()
$isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence();
// Only proceed for preview when not disabled; other routes unaffected
// Skip the block for privileged console users and resource tokens.
if ($isImageTransformation && $isImageTransformationsBlocked && !$isPrivilegedUser && !$isToken) {
// Skip the block only when transformations remain enabled.
if ($isImageTransformation && $isImageTransformationsBlocked) {
throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED);
}
@@ -636,7 +636,9 @@ App::init()
->addHeader('Cache-Control', sprintf('private, max-age=%d', $timestamp))
->addHeader('X-Appwrite-Cache', 'hit')
->setContentType($cacheLog->getAttribute('mimeType'));
if (!$isImageTransformation || !$isImageTransformationsBlocked) {
// Determine if user can bypass transformation blocks
$canBypassBlock = ($type === 'bucket') && ($isPrivilegedUser || $isToken);
if (!$isImageTransformation || !$isImageTransformationsBlocked || $canBypassBlock) {
$response->send($data);
}
} else {