mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
refactor: address coderabbitai comments
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user