Skip to content

Commit

Permalink
Add getWebxdcHref to json api (#6281)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodh authored Dec 2, 2024
1 parent 8ffe864 commit 3ad9cf3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion deltachat-jsonrpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ impl CommandApi {
account_id: u32,
instance_msg_id: u32,
update_str: String,
_descr: String,
_descr: Option<String>,
) -> Result<()> {
let ctx = self.get_context(account_id).await?;
ctx.send_webxdc_status_update(MsgId::new(instance_msg_id), &update_str)
Expand Down Expand Up @@ -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<Option<String>> {
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
Expand Down
6 changes: 6 additions & 0 deletions deltachat-jsonrpc/src/api/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ pub struct MessageObject {

webxdc_info: Option<WebxdcMessageInfo>,

webxdc_href: Option<String>,

download_state: DownloadState,

reactions: Option<JSONRPCReactions>,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3ad9cf3

Please sign in to comment.