drop the hive-side matrix code: sweep, hivectl matrix and the apiUrl option
This commit is contained in:
parent
a00bcb8c05
commit
6dbb18b6d4
1 changed files with 49 additions and 1007 deletions
|
|
@ -203,7 +203,6 @@ async fn dispatch(req: &HostRequest, coord: Arc<Coordinator>) -> HostResponse {
|
|||
// federation peer-config block) and open the web surfaces
|
||||
// (`hivectl open`).
|
||||
HostRequest::Urls => HostResponse::urls(hive_urls()),
|
||||
HostRequest::MatrixInvite { user, room } => handle_matrix_invite(user, room).await?,
|
||||
HostRequest::ReconcileConfigStatus { agent, verbose } => {
|
||||
crate::forge::reconcile_config_status(agent.as_str(), *verbose).await?
|
||||
}
|
||||
|
|
@ -343,25 +342,6 @@ async fn stream_agent_status(
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Matrix provisioning handlers
|
||||
//
|
||||
// The `hivectl matrix` subcommands used to run these in-process, which forced
|
||||
// the standalone CLI to link the whole daemon crate (matrix-sdk, reqwest, …).
|
||||
// They now run daemon-side over the host socket, where the daemon already holds
|
||||
// the sender token. Each op returns the operator-facing lines hivectl used to
|
||||
// `println!` in `HostResponse::messages` for the client to print verbatim.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Shared reqwest client for the matrix admin HTTP calls (30s timeout,
|
||||
/// mirroring the old in-CLI client).
|
||||
fn matrix_http_client() -> Result<reqwest::Client> {
|
||||
reqwest::Client::builder()
|
||||
.timeout(std::time::Duration::from_secs(30))
|
||||
.build()
|
||||
.context("build reqwest client")
|
||||
}
|
||||
|
||||
/// True when `name` has a state dir under the agents root, i.e. it's a
|
||||
/// managed agent rather than a bare (operator/human) account.
|
||||
///
|
||||
|
|
@ -375,21 +355,6 @@ fn agent_exists(name: &hive_types::Ident) -> Result<bool> {
|
|||
.with_context(|| format!("check agent state dir for {name}"))
|
||||
}
|
||||
|
||||
/// Guard: matrix provisioning needs a homeserver to provision against.
|
||||
///
|
||||
/// Answers "is one configured", not "is one running here": the address is
|
||||
/// the swarm's homeserver, wherever it runs.
|
||||
fn require_matrix_present() -> Result<()> {
|
||||
if crate::matrix::is_present() {
|
||||
return Ok(());
|
||||
}
|
||||
anyhow::bail!(
|
||||
"no matrix homeserver configured — set services.hyperhive.swarm.matrix.apiUrl (it defaults \
|
||||
to the swarm.matrix.gatewayHost vhost, and is null when that is) before provisioning \
|
||||
matrix users"
|
||||
)
|
||||
}
|
||||
|
||||
async fn handle_quota_enable() -> Result<HostResponse> {
|
||||
crate::priv_client::ensure_btrfs_quota()
|
||||
.await
|
||||
|
|
@ -498,26 +463,6 @@ async fn handle_push_snapshot(
|
|||
Ok(HostResponse::success())
|
||||
}
|
||||
|
||||
async fn handle_matrix_invite(user: &str, room: &str) -> Result<HostResponse> {
|
||||
require_matrix_present()?;
|
||||
let sender_token = crate::matrix::read_sender_token()?;
|
||||
let client = matrix_http_client()?;
|
||||
let server_name = crate::matrix::discover_server_name(&client)
|
||||
.await
|
||||
.context("discover matrix server_name")?;
|
||||
let room_id = crate::matrix::invite_user(&client, &sender_token, user, room, &server_name)
|
||||
.await
|
||||
.with_context(|| format!("matrix invite {user}"))?;
|
||||
let target = if user.starts_with('@') {
|
||||
user.to_owned()
|
||||
} else {
|
||||
format!("@{user}:{server_name}")
|
||||
};
|
||||
Ok(HostResponse::messages(vec![format!(
|
||||
"matrix: invited {target} to {room_id}"
|
||||
)]))
|
||||
}
|
||||
|
||||
/// Single-agent queue verbs the admin socket exposes. Each submits the
|
||||
/// matching DAG (persisting the `wanted` intent, serializing on the
|
||||
/// agent's lease, with the transient/crash-watch suppression the old
|
||||
|
|
|
|||
Loading…
Reference in a new issue