Human matrix accounts come from SSO, not hivectl. Matrix homeserver admin will come from authelia's admins group (sync tracked in #4585); password reset moves to swarm level (#4798). promote-user and reset-password were already broken from the hive: the hive's sender account has no admin sender to call the admin room with, only the swarm's does. Removes the three hivectl matrix verbs, their HostRequest variants, their hive-c0re handlers, and the admin-room helpers (discover room id, send-and-poll, event-id extraction, password/success parsing) that only they used. sync-admin and invite are unchanged. Refs #4585
54 lines
1.9 KiB
Rust
54 lines
1.9 KiB
Rust
//! `hivectl matrix` — matrix account provisioning verbs. hivectl forwards
|
|
//! each request to the daemon (which owns the register + sender tokens and
|
|
//! the matrix creds dir) and renders the reply; it no longer links the
|
|
//! matrix machinery itself.
|
|
|
|
use std::path::Path;
|
|
|
|
use anyhow::{Context as _, Result, bail};
|
|
|
|
use crate::cli::MatrixCmd;
|
|
|
|
/// Route a `matrix` subcommand to its handler. Extracted from `main`'s
|
|
/// dispatch match so the top-level router stays small.
|
|
pub(crate) async fn run_matrix_cmd(socket: &Path, cmd: MatrixCmd) -> Result<()> {
|
|
match cmd {
|
|
MatrixCmd::SyncAdmin => matrix_sync_admin(socket).await,
|
|
MatrixCmd::Invite { user, room } => matrix_invite(socket, &user, room.as_deref()).await,
|
|
}
|
|
}
|
|
|
|
/// Send a matrix provisioning request to the daemon and print the
|
|
/// operator-facing result lines it returns. The daemon owns the register +
|
|
/// sender tokens and the matrix creds dir, so hivectl no longer links the
|
|
/// matrix machinery — it just forwards the request and renders the reply.
|
|
async fn matrix_request(socket: &Path, req: hive_host_sock::HostRequest) -> Result<()> {
|
|
let resp = crate::client::request(socket, req)
|
|
.await
|
|
.with_context(|| format!("connect to daemon socket {}", socket.display()))?;
|
|
if !resp.ok {
|
|
bail!(
|
|
"matrix: {}",
|
|
resp.error.as_deref().unwrap_or("unknown error")
|
|
);
|
|
}
|
|
for line in &resp.messages {
|
|
println!("{line}");
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
async fn matrix_sync_admin(socket: &Path) -> Result<()> {
|
|
matrix_request(socket, hive_host_sock::HostRequest::MatrixSyncAdmin).await
|
|
}
|
|
|
|
async fn matrix_invite(socket: &Path, user: &str, room: Option<&str>) -> Result<()> {
|
|
matrix_request(
|
|
socket,
|
|
hive_host_sock::HostRequest::MatrixInvite {
|
|
user: user.to_owned(),
|
|
room: room.map(str::to_owned),
|
|
},
|
|
)
|
|
.await
|
|
}
|