fix: don't remove timeouts when a member leaves a server (#409)

This commit is contained in:
Tom
2025-09-06 18:41:23 -07:00
committed by GitHub
parent 3cb7da95e3
commit e635bc23ec
12 changed files with 778 additions and 449 deletions

View File

@@ -1,7 +1,7 @@
use revolt_config::configure;
use revolt_database::DatabaseInfo;
use revolt_result::Result;
use tasks::{file_deletion, prune_dangling_files};
use tasks::{file_deletion, prune_dangling_files, prune_members};
use tokio::try_join;
pub mod tasks;
@@ -13,7 +13,8 @@ async fn main() -> Result<()> {
let db = DatabaseInfo::Auto.connect().await.expect("database");
try_join!(
file_deletion::task(db.clone()),
prune_dangling_files::task(db)
prune_dangling_files::task(db.clone()),
prune_members::task(db.clone())
)
.map(|_| ())
}

View File

@@ -1,2 +1,3 @@
pub mod file_deletion;
pub mod prune_dangling_files;
pub mod prune_members;

View File

@@ -0,0 +1,18 @@
use std::time::Duration;
use log::warn;
use revolt_database::Database;
use revolt_result::Result;
use tokio::time::sleep;
pub async fn task(db: Database) -> Result<()> {
loop {
let success = db.remove_dangling_members().await;
if let Err(s) = success {
revolt_config::capture_error(&s);
warn!("Failed to prune dangling members: {:?}", &s);
}
sleep(Duration::from_secs(90)).await;
}
}