Remove user emails when deactivating a user

This commit is contained in:
Quentin Gliech
2025-03-11 10:16:42 +01:00
parent 10276b05fc
commit 4e2f38ea41
+9 -1
View File
@@ -11,7 +11,7 @@ use mas_storage::{
compat::CompatSessionFilter,
oauth2::OAuth2SessionFilter,
queue::{DeactivateUserJob, ReactivateUserJob},
user::{BrowserSessionFilter, UserRepository},
user::{BrowserSessionFilter, UserEmailFilter, UserRepository},
};
use tracing::info;
@@ -81,6 +81,14 @@ impl RunnableJob for DeactivateUserJob {
.map_err(JobError::retry)?;
info!(affected = n, "Killed all compatibility sessions for user");
// Delete all the email addresses for the user
let n = repo
.user_email()
.remove_bulk(UserEmailFilter::new().for_user(&user))
.await
.map_err(JobError::retry)?;
info!(affected = n, "Removed all email addresses for user");
// Before calling back to the homeserver, commit the changes to the database, as
// we want the user to be locked out as soon as possible
repo.save().await.map_err(JobError::retry)?;