JSON-RPC: add get_http_blob API

This commit is contained in:
link2xt
2023-04-18 12:52:36 +00:00
parent 0b832fb9de
commit 37503dd3e8
12 changed files with 88 additions and 77 deletions

View File

@@ -1610,6 +1610,17 @@ impl CommandApi {
Ok(general_purpose::STANDARD_NO_PAD.encode(blob))
}
/// Makes an HTTP GET request and returns base64-encoded contents.
///
/// `url` is the HTTP or HTTPS URL.
async fn get_http_blob(&self, account_id: u32, url: String) -> Result<String> {
let ctx = self.get_context(account_id).await?;
let blob = deltachat::net::read_url_blob(&ctx, &url).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,