Skip to content

Commit

Permalink
using &str is sufficient for set_webxdc_integration()
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Apr 16, 2024
1 parent 699093f commit 0044d25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deltachat-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 3 additions & 4 deletions src/webxdc/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/webxdc/maps_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down

0 comments on commit 0044d25

Please sign in to comment.