feat(#2035): auto-discover dashboard-provisioned matrix accounts via token+homeserver sidecar
This commit is contained in:
parent
cc73bc7cd0
commit
3b0a914487
6 changed files with 112 additions and 11 deletions
|
|
@ -247,6 +247,7 @@ async fn exec(req: PrivRequest, writer: &mut OwnedWriteHalf) -> Result<(String,
|
|||
ref agent_name,
|
||||
ref token,
|
||||
ref account,
|
||||
ref homeserver,
|
||||
} => {
|
||||
validate_agent_name(agent_name)?;
|
||||
// Build the token filename. `None` → the hive account's
|
||||
|
|
@ -262,7 +263,17 @@ async fn exec(req: PrivRequest, writer: &mut OwnedWriteHalf) -> Result<(String,
|
|||
format!("matrix-token-{a}")
|
||||
}
|
||||
};
|
||||
write_agent_state_file(agent_name, &filename, &format!("{token}\n"))
|
||||
let res = write_agent_state_file(agent_name, &filename, &format!("{token}\n"))?;
|
||||
// For an extra account, persist its homeserver in a sidecar
|
||||
// (`matrix-account-<a>.json`) so the daemon can auto-discover the
|
||||
// account without a static `matrixAccounts` config entry. Only
|
||||
// when both `account` and `homeserver` are present; the account
|
||||
// suffix is already validated above.
|
||||
if let (Some(a), Some(hs)) = (account, homeserver) {
|
||||
let meta = serde_json::json!({ "homeserver": hs }).to_string();
|
||||
write_agent_state_file(agent_name, &format!("matrix-account-{a}.json"), &meta)?;
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
PrivRequest::RestartMatrixDaemon { ref agent_name } => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue