1
0
Fork 0
mirror of synced 2024-10-02 02:07:04 +13:00

Merge pull request #6898 from appwrite/fix-6879-fix-project-delete

Update teamInternalId when updating project team
This commit is contained in:
Torsten Dittmann 2023-10-13 13:35:47 +02:00 committed by GitHub
commit ecd073fb02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -481,15 +481,43 @@ App::patch('/v1/projects/:projectId/team')
throw new Exception(Exception::TEAM_NOT_FOUND);
}
$project = $dbForConsole->updateDocument('projects', $project->getId(), $project
$permissions = [
Permission::read(Role::team(ID::custom($teamId))),
Permission::update(Role::team(ID::custom($teamId), 'owner')),
Permission::update(Role::team(ID::custom($teamId), 'developer')),
Permission::delete(Role::team(ID::custom($teamId), 'owner')),
Permission::delete(Role::team(ID::custom($teamId), 'developer')),
];
$project
->setAttribute('teamId', $teamId)
->setAttribute('$permissions', [
Permission::read(Role::team(ID::custom($teamId))),
Permission::update(Role::team(ID::custom($teamId), 'owner')),
Permission::update(Role::team(ID::custom($teamId), 'developer')),
Permission::delete(Role::team(ID::custom($teamId), 'owner')),
Permission::delete(Role::team(ID::custom($teamId), 'developer')),
]));
->setAttribute('teamInternalId', $team->getInternalId())
->setAttribute('$permissions', $permissions);
$project = $dbForConsole->updateDocument('projects', $project->getId(), $project);
$installations = $dbForConsole->find('installations', [
Query::equal('projectInternalId', [$project->getInternalId()]),
]);
foreach ($installations as $installation) {
$installation->getAttribute('$permissions', $permissions);
$dbForConsole->updateDocument('installations', $installation->getId(), $installation);
}
$repositories = $dbForConsole->find('repositories', [
Query::equal('projectInternalId', [$project->getInternalId()]),
]);
foreach ($repositories as $repository) {
$repository->getAttribute('$permissions', $permissions);
$dbForConsole->updateDocument('repositories', $repository->getId(), $repository);
}
$vcsComments = $dbForConsole->find('vcsComments', [
Query::equal('projectInternalId', [$project->getInternalId()]),
]);
foreach ($vcsComments as $vcsComment) {
$vcsComment->getAttribute('$permissions', $permissions);
$dbForConsole->updateDocument('vcsComments', $vcsComment->getId(), $vcsComment);
}
$response->dynamic($project, Response::MODEL_PROJECT);
});