1
0

Organization ownership (#796)

* organization changes

* changes

* fixes failing test

* version changes

* removed printlns

* add_team_member comes pre-accepted

* no notification on force accept

* fixes tests

* merge fixes
This commit is contained in:
Wyatt Verchere
2023-12-20 14:27:57 -08:00
committed by GitHub
parent 60c535e861
commit f7b4b782bf
31 changed files with 910 additions and 125 deletions

View File

@@ -256,31 +256,9 @@ impl Organization {
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
redis: &RedisPool,
) -> Result<Option<()>, super::DatabaseError> {
use futures::TryStreamExt;
let organization = Self::get_id(id, &mut **transaction, redis).await?;
if let Some(organization) = organization {
let projects: Vec<ProjectId> = sqlx::query!(
"
SELECT m.id
FROM mods m
WHERE m.organization_id = $1
",
id as OrganizationId,
)
.fetch_many(&mut **transaction)
.try_filter_map(|e| async { Ok(e.right().map(|m| ProjectId(m.id))) })
.try_collect::<Vec<ProjectId>>()
.await?;
for project_id in projects {
let _result =
super::project_item::Project::remove(project_id, transaction, redis).await?;
}
Organization::clear_cache(id, Some(organization.name), redis).await?;
sqlx::query!(
"
DELETE FROM organizations