From 0044d258121685401a0e355b626f23ec39a38c4e Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 16 Apr 2024 15:20:07 +0200 Subject: [PATCH] using &str is sufficient for set_webxdc_integration() --- deltachat-ffi/src/lib.rs | 2 +- src/webxdc/integration.rs | 7 +++---- src/webxdc/maps_integration.rs | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 293df2d98d..067b6004b1 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -1065,7 +1065,7 @@ pub unsafe extern "C" fn dc_set_webxdc_integration( return; } let ctx = &*context; - block_on(ctx.set_webxdc_integration(to_string_lossy(file))) + block_on(ctx.set_webxdc_integration(&to_string_lossy(file))) .log_err(ctx) .unwrap_or_default(); } diff --git a/src/webxdc/integration.rs b/src/webxdc/integration.rs index fe38efed78..2e4be68849 100644 --- a/src/webxdc/integration.rs +++ b/src/webxdc/integration.rs @@ -9,10 +9,10 @@ use anyhow::Result; impl Context { /// Set Webxdc file as integration. - pub async fn set_webxdc_integration(&self, file: String) -> Result<()> { + pub async fn set_webxdc_integration(&self, file: &str) -> Result<()> { let chat_id = ChatId::create_for_contact(self, ContactId::SELF).await?; let mut msg = Message::new(Viewtype::Webxdc); - msg.set_file(file.as_str(), None); + msg.set_file(file, None); msg.hidden = true; msg.param.set_int(Param::WebxdcIntegration, 1); msg.param.set_int(Param::GuaranteeE2ee, 1); // needed to pass `internet_access` requirements @@ -117,8 +117,7 @@ mod tests { let bytes = include_bytes!("../../test-data/webxdc/minimal.xdc"); let file = t.get_blobdir().join("maps.xdc"); tokio::fs::write(&file, bytes).await.unwrap(); - t.set_webxdc_integration(file.to_str().unwrap().to_string()) - .await?; + t.set_webxdc_integration(file.to_str().unwrap()).await?; // default integrations are shipped with the apps and should not be sent over the wire let sent = t.pop_sent_msg_opt(Duration::from_secs(1)).await; diff --git a/src/webxdc/maps_integration.rs b/src/webxdc/maps_integration.rs index 3035c4effc..38d3f5c0b1 100644 --- a/src/webxdc/maps_integration.rs +++ b/src/webxdc/maps_integration.rs @@ -183,8 +183,7 @@ mod tests { let bytes = include_bytes!("../../test-data/webxdc/mapstest.xdc"); let file = t.get_blobdir().join("maps.xdc"); tokio::fs::write(&file, bytes).await.unwrap(); - t.set_webxdc_integration(file.to_str().unwrap().to_string()) - .await?; + t.set_webxdc_integration(file.to_str().unwrap()).await?; let chatlist = Chatlist::try_load(&t, 0, None, None).await?; let summary = chatlist.get_summary(&t, 0, None).await?;