diff --git a/app/config/errors.php b/app/config/errors.php index 266e017e93..3b422bbc98 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -197,6 +197,11 @@ return [ 'description' => 'Team with the requested ID could not be found.', 'code' => 404, ], + Exception::PROJECT_TEAM_ALREADY_MATCHES => [ + 'name' => Exception::PROJECT_TEAM_ALREADY_MATCHES, + 'description' => 'Project already owned by this team.', + 'code' => 400, + ], Exception::TEAM_INVITE_ALREADY_EXISTS => [ 'name' => Exception::TEAM_INVITE_ALREADY_EXISTS, 'description' => 'User has already been invited or is already a member of this team', diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 0cd9a62b24..c642f59274 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -678,6 +678,10 @@ App::patch('/v1/projects/:projectId/team') throw new Exception(Exception::TEAM_NOT_FOUND); } + if ($team->getInternalId() === $project->getAttribute('teamInternalId')) { + throw new Exception(Exception::PROJECT_TEAM_ALREADY_MATCHES); + } + $project ->setAttribute('teamId', $team->getId()) ->setAttribute('teamInternalId', $team->getInternalId()) diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 8b240aa971..5da7f75593 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -76,6 +76,7 @@ class Exception extends \Exception /** Teams */ public const TEAM_NOT_FOUND = 'team_not_found'; + public const PROJECT_TEAM_ALREADY_MATCHES = 'project_team_already_matches'; public const TEAM_INVITE_ALREADY_EXISTS = 'team_invite_already_exists'; public const TEAM_INVITE_NOT_FOUND = 'team_invite_not_found'; public const TEAM_INVALID_SECRET = 'team_invalid_secret';