Sharded cluster node roles

This commit is contained in:
mdecimus
2025-10-20 12:10:36 +02:00
parent a4720e1efe
commit 59ab6d91ab
10 changed files with 105 additions and 29 deletions

View File

@@ -32,7 +32,7 @@ pub trait EmailDeletion: Sync + Send {
document_ids: RoaringBitmap,
) -> impl Future<Output = trc::Result<RoaringBitmap>> + Send;
fn purge_accounts(&self) -> impl Future<Output = ()> + Send;
fn purge_accounts(&self, use_roles: bool) -> impl Future<Output = ()> + Send;
fn purge_account(&self, account_id: u32) -> impl Future<Output = ()> + Send;
@@ -99,10 +99,21 @@ impl EmailDeletion for Server {
Ok(not_destroyed)
}
async fn purge_accounts(&self) {
async fn purge_accounts(&self, use_roles: bool) {
if let Ok(Some(account_ids)) = self.get_document_ids(u32::MAX, Collection::Principal).await
{
let mut account_ids: Vec<u32> = account_ids.into_iter().collect();
let mut account_ids: Vec<u32> = account_ids
.into_iter()
.filter(|id| {
!use_roles
|| self
.core
.network
.roles
.purge_accounts
.is_enabled_for_account(*id)
})
.collect();
// Shuffle account ids
account_ids.shuffle(&mut store::rand::rng());