From 8a4dff2212550ddf193f1b04b18d721f78b9dab3 Mon Sep 17 00:00:00 2001 From: Nico de Haen Date: Wed, 8 May 2024 07:53:04 +0200 Subject: [PATCH] Add webxdc internal integration commands in jsonrpc (#5541) Adds _setWebxdcIntegration_ _initWebxdcIntegration_ --- deltachat-jsonrpc/src/api.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index b0b05e222..c0ebfb52d 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -1771,6 +1771,29 @@ impl CommandApi { Ok(general_purpose::STANDARD_NO_PAD.encode(blob)) } + /// Sets Webxdc file as integration. + /// `file` is the .xdc to use as Webxdc integration. + async fn set_webxdc_integration(&self, account_id: u32, file_path: String) -> Result<()> { + let ctx = self.get_context(account_id).await?; + ctx.set_webxdc_integration(&file_path).await + } + + /// Returns Webxdc instance used for optional integrations. + /// UI can open the Webxdc as usual. + /// Returns `None` if there is no integration; the caller can add one using `set_webxdc_integration` then. + /// `integrate_for` is the chat to get the integration for. + async fn init_webxdc_integration( + &self, + account_id: u32, + chat_id: Option, + ) -> Result> { + let ctx = self.get_context(account_id).await?; + Ok(ctx + .init_webxdc_integration(chat_id.map(ChatId::new)) + .await? + .map(|msg_id| msg_id.to_u32())) + } + /// Makes an HTTP GET request and returns a response. /// /// `url` is the HTTP or HTTPS URL.