mirror of
https://github.com/chatmail/core.git
synced 2026-10-03 03:30:36 +03:00
feat: client version information
This commit is contained in:
@@ -64,6 +64,7 @@ use self::types::{
|
||||
JsonrpcMessageListItem, MessageNotificationInfo, MessageSearchResult, MessageViewtype,
|
||||
},
|
||||
};
|
||||
use crate::api::types::appversions::JsonrpcAppVersionInfo;
|
||||
use crate::api::types::chat_list::{ChatListItemFetchResult, get_chat_list_item_by_id};
|
||||
use crate::api::types::login_param::TransportListEntry;
|
||||
use crate::api::types::qr::{QrObject, SecurejoinSource, SecurejoinUiPath};
|
||||
@@ -2789,6 +2790,13 @@ impl CommandApi {
|
||||
Err(anyhow!("chat with id {chat_id} doesn't have draft message"))
|
||||
}
|
||||
}
|
||||
|
||||
/// Get version information of clients.
|
||||
async fn get_app_versions(&self, account_id: u32) -> Result<JsonrpcAppVersionInfo> {
|
||||
let ctx = self.get_context(account_id).await?;
|
||||
let info = deltachat::appversions::get_app_versions(&ctx).await?;
|
||||
JsonrpcAppVersionInfo::from_core_type(info)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions (to prevent code duplication)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
use anyhow::Result;
|
||||
use deltachat::appversions::AppVersionInfo;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typescript_type_def::TypeDef;
|
||||
|
||||
/// Version information of clients.
|
||||
#[derive(Serialize, Deserialize, TypeDef, schemars::JsonSchema)]
|
||||
#[serde(rename = "AppVersionInfo", rename_all = "camelCase")]
|
||||
pub struct JsonrpcAppVersionInfo {
|
||||
/// Array of clients with version information.
|
||||
pub clients: Vec<JsonrpcAppClient>,
|
||||
}
|
||||
|
||||
/// Version information of a single client, eg. "deltachat" or "ubuntutouch".
|
||||
#[derive(Serialize, Deserialize, TypeDef, schemars::JsonSchema)]
|
||||
#[serde(rename = "AppClient", rename_all = "camelCase")]
|
||||
pub struct JsonrpcAppClient {
|
||||
/// ID how the client identifies itself, eg. "deltachat" or "ubuntutouch".
|
||||
pub client_id: String,
|
||||
|
||||
/// Array of sources for that client.
|
||||
pub sources: Vec<JsonrpcAppSource>,
|
||||
}
|
||||
|
||||
/// Version information of a single source of a client, eg. "gplay" or "fdroid".
|
||||
#[derive(Serialize, Deserialize, TypeDef, schemars::JsonSchema)]
|
||||
#[serde(rename = "AppSource", rename_all = "camelCase")]
|
||||
pub struct JsonrpcAppSource {
|
||||
/// ID how the client identifies a source, eg. "gplay" or "fdroid".
|
||||
pub app_id: String,
|
||||
|
||||
/// Always increasing version number.
|
||||
pub version_integer: u32,
|
||||
|
||||
/// Any version string.
|
||||
pub version_string: String,
|
||||
|
||||
/// Where to download that version.
|
||||
pub download_url: String,
|
||||
}
|
||||
|
||||
impl JsonrpcAppVersionInfo {
|
||||
pub fn from_core_type(info: AppVersionInfo) -> Result<Self> {
|
||||
let value = serde_json::to_value(info)?;
|
||||
Ok(serde_json::from_value(value)?)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod account;
|
||||
pub mod appversions;
|
||||
pub mod calls;
|
||||
pub mod chat;
|
||||
pub mod chat_list;
|
||||
|
||||
Reference in New Issue
Block a user