Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions apps/labrinth/src/database/models/user_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,18 @@ impl User {
.execute(&mut **transaction)
.await?;

sqlx::query!(
"
UPDATE charges
SET user_id = $1
WHERE user_id = $2
",
deleted_user as UserId,
id as UserId,
)
.execute(&mut **transaction)
.await?;

sqlx::query!(
"
DELETE FROM user_backup_codes
Expand Down
33 changes: 20 additions & 13 deletions apps/labrinth/src/routes/v3/teams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,19 +936,26 @@ pub async fn transfer_ownership(
let mut transaction = pool.begin().await?;

// The following are the only places new_is_owner is modified.
TeamMember::edit_team_member(
id.into(),
current_user.id.into(),
None,
None,
None,
None,
None,
None,
Some(false),
&mut transaction,
)
.await?;
if let Some(former_owner) =
TeamMember::get_from_team_full(id.into(), &**pool, &redis)
.await?
.into_iter()
.find(|x| x.is_owner)
{
TeamMember::edit_team_member(
id.into(),
former_owner.user_id,
None,
None,
None,
None,
None,
None,
Some(false),
&mut transaction,
)
.await?;
}

TeamMember::edit_team_member(
id.into(),
Expand Down
Loading