From 3ad9cf3c749adc72883ba813612e542ada810fdb Mon Sep 17 00:00:00 2001 From: Nico de Haen Date: Mon, 2 Dec 2024 06:58:43 +0100 Subject: [PATCH] Add getWebxdcHref to json api (#6281) --- deltachat-jsonrpc/src/api.rs | 14 +++++++++++++- deltachat-jsonrpc/src/api/types/message.rs | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 331f8594e..cb6260d1c 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -1767,7 +1767,7 @@ impl CommandApi { account_id: u32, instance_msg_id: u32, update_str: String, - _descr: String, + _descr: Option, ) -> Result<()> { let ctx = self.get_context(account_id).await?; ctx.send_webxdc_status_update(MsgId::new(instance_msg_id), &update_str) @@ -1829,6 +1829,18 @@ impl CommandApi { WebxdcMessageInfo::get_for_message(&ctx, MsgId::new(instance_msg_id)).await } + /// Get href from a WebxdcInfoMessage which might include a hash holding + /// information about a specific position or state in a webxdc app (optional) + async fn get_webxdc_href( + &self, + account_id: u32, + instance_msg_id: u32, + ) -> Result> { + let ctx = self.get_context(account_id).await?; + let message = Message::load_from_db(&ctx, MsgId::new(instance_msg_id)).await?; + Ok(message.get_webxdc_href()) + } + /// Get blob encoded as base64 from a webxdc message /// /// path is the path of the file within webxdc archive diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index 9511fcd08..72767ebd9 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -85,6 +85,8 @@ pub struct MessageObject { webxdc_info: Option, + webxdc_href: Option, + download_state: DownloadState, reactions: Option, @@ -241,6 +243,10 @@ impl MessageObject { file_name: message.get_filename(), webxdc_info, + // On a WebxdcInfoMessage this might include a hash holding + // information about a specific position or state in a webxdc app + webxdc_href: message.get_webxdc_href(), + download_state, reactions,