refactor(#2302): type socket wire fields as ident, validated by serde on deserialize
This commit is contained in:
parent
bf644cc126
commit
84b750fba5
33 changed files with 333 additions and 263 deletions
|
|
@ -425,7 +425,7 @@ async fn handle_get_agent_meta(
|
|||
// the OS level. Validate it before any path is built. The `None` default
|
||||
// (`target == agent`) is the caller's own authenticated name, already
|
||||
// valid — but validating unconditionally is simplest and harmless.
|
||||
let target_id = match hive_host_sock::Ident::parse(target) {
|
||||
let target_id = match hive_types::Ident::parse(target) {
|
||||
Ok(id) => id,
|
||||
Err(reason) => {
|
||||
return hive_agent_sock::Response::Err {
|
||||
|
|
@ -461,7 +461,7 @@ async fn handle_get_agent_meta(
|
|||
/// or the daemon not up yet) yields an empty list. The `MatrixIdentity`
|
||||
/// serde shape matches the snapshot entries; the snapshot's `live` field is
|
||||
/// ignored (only live accounts are written).
|
||||
fn read_agent_matrix_identities(agent: &hive_host_sock::Ident) -> Vec<hive_sh4re::MatrixIdentity> {
|
||||
fn read_agent_matrix_identities(agent: &hive_types::Ident) -> Vec<hive_sh4re::MatrixIdentity> {
|
||||
let path = Coordinator::agent_notes_dir(agent).join("matrix-accounts.json");
|
||||
std::fs::read_to_string(&path)
|
||||
.ok()
|
||||
|
|
@ -751,7 +751,7 @@ fn require_group(agent: &str, group: &str, action: &str) -> Option<Response> {
|
|||
/// `submit_init_config`, which builds filesystem paths from it, so validate
|
||||
/// before that.
|
||||
fn require_new_child(agent: &str, target: &str, action: &str) -> Option<Response> {
|
||||
if let Err(reason) = hive_host_sock::Ident::parse(target) {
|
||||
if let Err(reason) = hive_types::Ident::parse(target) {
|
||||
return Some(Response::Err {
|
||||
message: format!("agent `{agent}` cannot {action} `{target}`: {reason}"),
|
||||
});
|
||||
|
|
@ -1118,7 +1118,7 @@ pub(crate) fn handle_send(
|
|||
// A name that doesn't parse as an Ident can't be a local agent, so
|
||||
// it collapses into the same "unknown recipient" error as a valid
|
||||
// name with no state dir.
|
||||
let exists = hive_host_sock::Ident::parse(&resolved)
|
||||
let exists = hive_types::Ident::parse(&resolved)
|
||||
.is_ok_and(|id| crate::paths::agent_state_dir(&id).exists());
|
||||
if !exists {
|
||||
return Response::Err {
|
||||
|
|
|
|||
Loading…
Reference in a new issue