From 2d25514dd8c666bc590eb904eed21874c554d857 Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Fri, 10 Mar 2023 13:36:31 +0000 Subject: [PATCH] Improve 409 rule error; update console --- app/config/collections.php | 7 ------- app/config/errors.php | 2 +- app/console | 2 +- app/controllers/api/proxy.php | 15 ++++++++++++++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 6ae32769c9..3cabf4d361 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -892,13 +892,6 @@ $collections = [ 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], - [ - '$id' => ID::custom('_key_redirect'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['redirect'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], [ '$id' => ID::custom('_key_status'), 'type' => Database::INDEX_KEY, diff --git a/app/config/errors.php b/app/config/errors.php index 98b1c34dd2..a501ebafb9 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -546,7 +546,7 @@ return [ ], Exception::RULE_ALREADY_EXISTS => [ 'name' => Exception::RULE_ALREADY_EXISTS, - 'description' => 'A rule with the requested domain already exists.', + 'description' => 'Domain already used.', 'code' => 409, ], Exception::RULE_VERIFICATION_FAILED => [ diff --git a/app/console b/app/console index 2a01dc8237..884a5ba74c 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit 2a01dc82378c8c8c5e1188dcfe8b98d246a963d7 +Subproject commit 884a5ba74cc0b7755bcb21caedf5b1a68acdca05 diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index de644d5c2b..1f6d7c189e 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -49,7 +49,20 @@ App::post('/v1/proxy/rules') ]); if ($document && !$document->isEmpty()) { - throw new Exception(Exception::RULE_ALREADY_EXISTS); + if($document->getAttribute('projectId') === $project->getId()) { + $resourceType = $document->getAttribute('resourceType'); + $resourceId = $document->getAttribute('resourceId'); + $message = "Domain already assigned to '{$resourceType}' service"; + if(!empty($resourceId)) { + $message .= " with ID '{$resourceId}'"; + } + + $message .= '.'; + } else { + $message = "Domain already assigned to different project."; + } + + throw new Exception(Exception::RULE_ALREADY_EXISTS, $message); } $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));