jsonrpc(feat): Add API to get json encryption info

Add a new api to jsonrpc that returns json structured data about chat encryption.
This commit is contained in:
Sebastian Klähn
2024-11-10 11:39:26 +01:00
parent 3b2f18f926
commit 5fde02f9fd
3 changed files with 78 additions and 1 deletions

View File

@@ -45,7 +45,7 @@ pub mod types;
use num_traits::FromPrimitive;
use types::account::Account;
use types::chat::FullChat;
use types::chat::{EncryptionInfo, FullChat};
use types::contact::{ContactObject, VcardContact};
use types::events::Event;
use types::http::HttpResponse;
@@ -708,6 +708,19 @@ impl CommandApi {
ChatId::new(chat_id).get_encryption_info(&ctx).await
}
/// Get encryption info for a chat.
async fn get_chat_encryption_info_json(
&self,
account_id: u32,
chat_id: u32,
) -> Result<EncryptionInfo> {
let ctx = self.get_context(account_id).await?;
Ok(ChatId::new(chat_id)
.get_encryption_info_json(&ctx)
.await?
.into())
}
/// Get QR code text that will offer a [SecureJoin](https://securejoin.delta.chat/) invitation.
///
/// If `chat_id` is a group chat ID, SecureJoin QR code for the group is returned.