Compare commits

...

2 Commits

Author SHA1 Message Date
Simon Laux
6df71e9e9f fix: add multi-transport information to Context.get_info (own key for
each transport, alternative to #7583)
2025-12-09 10:32:49 +01:00
Simon Laux
f0e6942438 fix add multi-transport information to Context.get_info 2025-12-09 10:09:28 +01:00
3 changed files with 13 additions and 5 deletions

View File

@@ -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<String, std::fmt::Error> {
fn render_info(info: BTreeMap<String, String>) -> std::result::Result<String, std::fmt::Error> {
let mut res = String::new();
for (key, value) in &info {
writeln!(&mut res, "{key}={value}")?;

View File

@@ -363,7 +363,7 @@ impl CommandApi {
}
/// Get system info for an account.
async fn get_info(&self, account_id: u32) -> Result<BTreeMap<&'static str, String>> {
async fn get_info(&self, account_id: u32) -> Result<BTreeMap<String, String>> {
let ctx = self.get_context(account_id).await?;
ctx.get_info().await
}

View File

@@ -815,13 +815,14 @@ impl Context {
******************************************************************************/
/// Returns information about the context as key-value pairs.
pub async fn get_info(&self) -> Result<BTreeMap<&'static str, String>> {
pub async fn get_info(&self) -> Result<BTreeMap<String, String>> {
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 = 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;
@@ -1098,6 +1099,15 @@ impl Context {
let elapsed = time_elapsed(&self.creation_time);
res.insert("uptime", duration_to_str(elapsed));
let mut res: BTreeMap<String, String> = 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)
}