matrix multi-account: isolate per-account stale-token failure so a bad secondary token doesn't kill the daemon
This commit is contained in:
parent
c27f915e47
commit
e5cd4e58f1
2 changed files with 44 additions and 26 deletions
|
|
@ -17,8 +17,12 @@
|
|||
//! provisions it. A SECONDARY account missing its token is skipped (the
|
||||
//! daemon still serves the others).
|
||||
//!
|
||||
//! Stale-token recovery: handled in `client::build_and_restore` — see
|
||||
//! that module for the `M_UNKNOWN_TOKEN` detection + cleanup flow.
|
||||
//! Stale-token recovery (`M_UNKNOWN_TOKEN`): handled in
|
||||
//! `client::build_and_restore`, and it mirrors the missing-token policy
|
||||
//! above — a rejected PRIMARY token drops the stale token + sdk state and
|
||||
//! exits 0 for systemd re-provisioning, while a rejected SECONDARY token
|
||||
//! is removed and that one account is skipped so the daemon keeps serving
|
||||
//! the primary and any other healthy account.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -65,7 +69,7 @@ async fn main() -> Result<()> {
|
|||
// Account-tag the wakes only in multi-account mode so single-
|
||||
// account wake bodies stay byte-identical to the legacy format.
|
||||
let tag = multi.then(|| cfg.name.clone());
|
||||
match bring_up_account(&cfg, &hyperhive_socket, tag).await {
|
||||
match bring_up_account(&cfg, &hyperhive_socket, tag, is_primary).await {
|
||||
Ok(Some((client, sync_loop))) => {
|
||||
registry.insert(cfg.name, client);
|
||||
sync_loops.push(sync_loop);
|
||||
|
|
@ -137,6 +141,7 @@ async fn bring_up_account(
|
|||
cfg: &AccountCfg,
|
||||
hyperhive_socket: &std::path::Path,
|
||||
tag: Option<String>,
|
||||
is_primary: bool,
|
||||
) -> Result<Option<(Client, SyncLoop)>> {
|
||||
let homeserver = cfg.homeserver();
|
||||
if !tokio::fs::try_exists(&cfg.token_file)
|
||||
|
|
@ -152,9 +157,10 @@ async fn bring_up_account(
|
|||
state_dir = %cfg.state_dir.display(),
|
||||
"bringing up matrix account"
|
||||
);
|
||||
let client = client::build_and_restore(&homeserver, &cfg.token_file, &cfg.state_dir)
|
||||
.await
|
||||
.with_context(|| format!("build matrix client for account {}", cfg.name))?;
|
||||
let client =
|
||||
client::build_and_restore(&homeserver, &cfg.token_file, &cfg.state_dir, is_primary)
|
||||
.await
|
||||
.with_context(|| format!("build matrix client for account {}", cfg.name))?;
|
||||
timeline::install_message_handler(&client, hyperhive_socket.to_path_buf(), tag.clone());
|
||||
|
||||
let sync_client = client.clone();
|
||||
|
|
|
|||
Loading…
Reference in a new issue