From 6df71e9e9fac11aa5873b077ee407f5b12411dcc Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Tue, 9 Dec 2025 10:32:49 +0100 Subject: [PATCH] fix: add multi-transport information to Context.get_info (own key for each transport, alternative to #7583) --- deltachat-ffi/src/lib.rs | 4 +--- deltachat-jsonrpc/src/api.rs | 2 +- src/context.rs | 23 +++++++++++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index e92f30a55..955a87527 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -356,9 +356,7 @@ pub unsafe extern "C" fn dc_get_info(context: *const dc_context_t) -> *mut libc: } } -fn render_info( - info: BTreeMap<&'static str, String>, -) -> std::result::Result { +fn render_info(info: BTreeMap) -> std::result::Result { let mut res = String::new(); for (key, value) in &info { writeln!(&mut res, "{key}={value}")?; diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 7f1d57b48..b3c395f9d 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -363,7 +363,7 @@ impl CommandApi { } /// Get system info for an account. - async fn get_info(&self, account_id: u32) -> Result> { + async fn get_info(&self, account_id: u32) -> Result> { let ctx = self.get_context(account_id).await?; ctx.get_info().await } diff --git a/src/context.rs b/src/context.rs index 737d66cd0..5b6bf0eeb 100644 --- a/src/context.rs +++ b/src/context.rs @@ -815,23 +815,14 @@ impl Context { ******************************************************************************/ /// Returns information about the context as key-value pairs. - pub async fn get_info(&self) -> Result> { + pub async fn get_info(&self) -> Result> { let l = EnteredLoginParam::load(self).await?; let l2 = ConfiguredLoginParam::load(self).await?.map_or_else( || "Not configured".to_string(), |(_transport_id, param)| param.to_string(), ); let secondary_addrs = self.get_secondary_self_addrs().await?.join(", "); - let all_transports: Vec = ConfiguredLoginParam::load_all(self) - .await? - .into_iter() - .map(|(transport_id, param)| format!("{transport_id}: {param}")) - .collect(); - let all_transports = if all_transports.is_empty() { - "Not configured".to_string() - } else { - all_transports.join(",") - }; + let all_transports = ConfiguredLoginParam::load_all(self).await?; let chats = get_chat_cnt(self).await?; let unblocked_msgs = message::get_unblocked_msg_cnt(self).await; let request_msgs = message::get_request_msg_cnt(self).await; @@ -912,7 +903,6 @@ impl Context { res.insert("proxy_enabled", proxy_enabled.to_string()); res.insert("entered_account_settings", l.to_string()); res.insert("used_account_settings", l2); - res.insert("used_transport_settings", all_transports); if let Some(server_id) = &*self.server_id.read().await { res.insert("imap_server_id", format!("{server_id:?}")); @@ -1109,6 +1099,15 @@ impl Context { let elapsed = time_elapsed(&self.creation_time); res.insert("uptime", duration_to_str(elapsed)); + let mut res: BTreeMap = res + .into_iter() + .map(|(key, value)| (key.to_owned(), value)) + .collect(); + + for (transport_id, param) in &all_transports { + res.insert(format!("transport{transport_id}"), param.to_string()); + } + Ok(res) }