use super::RpcHandler; use crate::update; use anyhow::Result; impl RpcHandler { /// Check for available system updates. pub(super) async fn handle_update_check(&self) -> Result { let state = update::check_for_updates(&self.config.data_dir).await?; let update_info = state.available_update.as_ref().map(|u| { serde_json::json!({ "version": u.version, "release_date": u.release_date, "changelog": u.changelog, "components": u.components.len(), }) }); Ok(serde_json::json!({ "current_version": state.current_version, "last_check": state.last_check, "update_available": update_info.is_some(), "update": update_info, })) } /// Get update status without checking remote. pub(super) async fn handle_update_status(&self) -> Result { let state = update::get_status(&self.config.data_dir).await?; Ok(serde_json::json!({ "current_version": state.current_version, "last_check": state.last_check, "update_available": state.available_update.is_some(), "update_in_progress": state.update_in_progress, "rollback_available": state.rollback_available, })) } /// Dismiss the update notification. pub(super) async fn handle_update_dismiss(&self) -> Result { update::dismiss_update(&self.config.data_dir).await?; Ok(serde_json::json!({ "ok": true })) } }