jsonrpc: add get webxdc blob API getWebxdcBlob (#4070)

* jsonrpc: add get webxdc blob API `getWebxdcBlob`

* add info about path

* format
This commit is contained in:
Simon Laux
2023-02-27 18:46:13 +01:00
committed by GitHub
parent c79ded1406
commit fc019de18c
4 changed files with 49 additions and 18 deletions

View File

@@ -1463,6 +1463,23 @@ impl CommandApi {
WebxdcMessageInfo::get_for_message(&ctx, MsgId::new(instance_msg_id)).await
}
/// Get blob encoded as base64 from a webxdc message
///
/// path is the path of the file within webxdc archive
async fn get_webxdc_blob(
&self,
account_id: u32,
instance_msg_id: u32,
path: String,
) -> Result<String> {
let ctx = self.get_context(account_id).await?;
let message = Message::load_from_db(&ctx, MsgId::new(instance_msg_id)).await?;
let blob = message.get_webxdc_blob(&ctx, &path).await?;
use base64::{engine::general_purpose, Engine as _};
Ok(general_purpose::STANDARD_NO_PAD.encode(blob))
}
/// Forward messages to another chat.
///
/// All types of messages can be forwarded,