huskies: merge 766
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
//! spawning the Matrix bot task, and the notification poller background task.
|
||||
|
||||
use super::config::{GatewayConfig, ProjectEntry};
|
||||
use super::registration::JoinedAgent;
|
||||
pub use reqwest::Client;
|
||||
use serde_json::{Value, json};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
@@ -20,16 +19,6 @@ pub fn load_config(path: &Path) -> Result<GatewayConfig, String> {
|
||||
toml::from_str(&contents).map_err(|e| format!("invalid projects.toml: {e}"))
|
||||
}
|
||||
|
||||
/// Load persisted agents from `<config_dir>/gateway_agents.json`.
|
||||
/// Returns an empty list if the file does not exist or cannot be parsed.
|
||||
pub fn load_agents(config_dir: &Path) -> Vec<JoinedAgent> {
|
||||
let path = config_dir.join("gateway_agents.json");
|
||||
match std::fs::read(&path) {
|
||||
Ok(data) => serde_json::from_slice(&data).unwrap_or_default(),
|
||||
Err(_) => Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Persist the current projects map to `<config_dir>/projects.toml`.
|
||||
/// Silently ignores write errors or skips when `config_dir` is empty.
|
||||
pub async fn save_config(projects: &BTreeMap<String, ProjectEntry>, config_dir: &Path) {
|
||||
@@ -45,18 +34,6 @@ pub async fn save_config(projects: &BTreeMap<String, ProjectEntry>, config_dir:
|
||||
}
|
||||
}
|
||||
|
||||
/// Persist the current agent list to `<config_dir>/gateway_agents.json`.
|
||||
/// Silently ignores write errors.
|
||||
pub async fn save_agents(agents: &[JoinedAgent], config_dir: &Path) {
|
||||
if config_dir == Path::new("") {
|
||||
return;
|
||||
}
|
||||
let path = config_dir.join("gateway_agents.json");
|
||||
if let Ok(data) = serde_json::to_vec_pretty(agents) {
|
||||
let _ = tokio::fs::write(&path, data).await;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Bot config I/O ──────────────────────────────────────────────────────────
|
||||
|
||||
/// Read the current raw bot.toml as key/value pairs for the configuration UI.
|
||||
|
||||
Reference in New Issue
Block a user