fix(#2557): sweep unread rooms post-sync so a dropped matrix wake self-heals

This commit is contained in:
damocles 2026-07-17 15:44:04 +02:00 committed by mara
commit 742ed51d57
3 changed files with 96 additions and 133 deletions

View file

@ -290,21 +290,28 @@ async fn bring_up_account(
// flagged "unverified" in other users' clients. Idempotent + swallows
// failures (a UIAA-requiring homeserver) inside ensure_cross_signing.
client::ensure_cross_signing(&client, &cfg.name).await;
timeline::install_message_handler(&client, hyperhive_socket.to_path_buf(), tag.clone());
let sync_client = client.clone();
let cb_client = client.clone();
let invite_socket = Arc::new(hyperhive_socket.to_path_buf());
let wake_socket = Arc::new(hyperhive_socket.to_path_buf());
// Separate dedup sets: one tracks invites already woken about, the
// other unread-message rooms. Both are pruned to their current state
// each sweep (see the sweep fns) so re-invites / new messages re-wake.
let invite_notified = Arc::new(tokio::sync::Mutex::new(std::collections::HashSet::new()));
let unread_notified = Arc::new(tokio::sync::Mutex::new(std::collections::HashSet::new()));
let sync_loop: SyncLoop = Box::pin(async move {
sync_client
.sync_with_callback(SyncSettings::default(), move |_response| {
let client = cb_client.clone();
let socket = invite_socket.clone();
let notified = invite_notified.clone();
let socket = wake_socket.clone();
let invite_notified = invite_notified.clone();
let unread_notified = unread_notified.clone();
let tag = tag.clone();
async move {
timeline::sweep_invites(&client, &socket, &notified, tag.as_deref()).await;
timeline::sweep_invites(&client, &socket, &invite_notified, tag.as_deref())
.await;
timeline::sweep_unread(&client, &socket, &unread_notified, tag.as_deref())
.await;
matrix_sdk::LoopCtrl::Continue
}
})