mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
refactor: address review comment; introduce new exception class
This commit is contained in:
@@ -497,6 +497,11 @@ return [
|
||||
'description' => 'The requested file is not publicly readable.',
|
||||
'code' => 403,
|
||||
],
|
||||
Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED => [
|
||||
'name' => Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED,
|
||||
'description' => 'Image transformations are disabled for this storage bucket.',
|
||||
'code' => 401,
|
||||
],
|
||||
|
||||
/** Tokens */
|
||||
Exception::TOKEN_NOT_FOUND => [
|
||||
|
||||
@@ -993,7 +993,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
|
||||
$allowImageTransformations = $bucket->getAttribute('imageTransformations', true);
|
||||
if (!$allowImageTransformations && !$isToken) {
|
||||
// Image transformations are disabled for this bucket
|
||||
throw new Exception(Exception::USER_UNAUTHORIZED);
|
||||
throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED);
|
||||
}
|
||||
|
||||
if ($fileSecurity && !$valid && !$isToken) {
|
||||
|
||||
@@ -591,7 +591,7 @@ App::init()
|
||||
// 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) {
|
||||
throw new Exception(Exception::USER_UNAUTHORIZED);
|
||||
throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED);
|
||||
}
|
||||
|
||||
if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAppUser && !$isPrivilegedUser)) {
|
||||
|
||||
@@ -148,6 +148,7 @@ class Exception extends \Exception
|
||||
public const STORAGE_INVALID_RANGE = 'storage_invalid_range';
|
||||
public const STORAGE_INVALID_APPWRITE_ID = 'storage_invalid_appwrite_id';
|
||||
public const STORAGE_FILE_NOT_PUBLIC = 'storage_file_not_public';
|
||||
public const STORAGE_IMAGE_TRANSFORMATIONS_DISABLED = 'storage_image_transformations_disabled';
|
||||
|
||||
/** VCS */
|
||||
public const INSTALLATION_NOT_FOUND = 'installation_not_found';
|
||||
|
||||
Reference in New Issue
Block a user