mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
detect maps-integration based on manifest entry
This commit is contained in:
@@ -2636,7 +2636,7 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> {
|
||||
{
|
||||
if better_type != Viewtype::Webxdc
|
||||
|| context
|
||||
.ensure_sendable_webxdc_file(&blob.to_abs_path())
|
||||
.prepare_webxdc_file(&blob.to_abs_path(), msg)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
@@ -2645,7 +2645,7 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> {
|
||||
}
|
||||
} else if msg.viewtype == Viewtype::Webxdc {
|
||||
context
|
||||
.ensure_sendable_webxdc_file(&blob.to_abs_path())
|
||||
.prepare_webxdc_file(&blob.to_abs_path(), msg)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -2913,7 +2913,7 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
|
||||
recipients.push(from);
|
||||
}
|
||||
|
||||
// Webxdc integrations are messages, however, shipped with main app and must not be sent out
|
||||
// Webxdc integrations are local (shipped with app or added to "Saved Messages") and must not be sent out
|
||||
if msg.param.get_int(Param::WebxdcIntegration).is_some() {
|
||||
recipients.clear();
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ pub struct WebxdcManifest {
|
||||
/// Optional URL of webxdc source code.
|
||||
pub source_code_url: Option<String>,
|
||||
|
||||
/// If the webxdc is an integration.
|
||||
pub integration: Option<String>,
|
||||
|
||||
/// If the webxdc requests network access.
|
||||
pub request_internet_access: Option<bool>,
|
||||
}
|
||||
@@ -220,7 +223,8 @@ impl Context {
|
||||
}
|
||||
|
||||
/// Ensure that a file is an acceptable webxdc for sending.
|
||||
pub(crate) async fn ensure_sendable_webxdc_file(&self, path: &Path) -> Result<()> {
|
||||
/// Moreover, check if the webxdc is an integration and add that information to the message object.
|
||||
pub(crate) async fn prepare_webxdc_file(&self, path: &Path, msg: &mut Message) -> Result<()> {
|
||||
let filename = path.to_str().unwrap_or_default();
|
||||
if !filename.ends_with(WEBXDC_SUFFIX) {
|
||||
bail!("{} is not a valid webxdc file", filename);
|
||||
@@ -232,6 +236,16 @@ impl Context {
|
||||
warn!(self, "{} misses index.html", filename);
|
||||
false
|
||||
} else {
|
||||
if let Ok(bytes) = get_blob(&archive, "manifest.toml").await {
|
||||
if let Ok(manifest) = parse_webxdc_manifest(&bytes) {
|
||||
if let Some(integration) = manifest.integration {
|
||||
if integration == "maps" {
|
||||
msg.param.set_int(Param::WebxdcIntegration, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ impl Context {
|
||||
let mut msg = Message::new(Viewtype::Webxdc);
|
||||
msg.set_file(file, None);
|
||||
msg.hidden = true;
|
||||
msg.param.set_int(Param::WebxdcIntegration, 1);
|
||||
msg.param.set_int(Param::WebxdcIntegration, 1); // can be removed when all UI upgraded to maps.xdc having integration=maps in the manifest
|
||||
msg.param.set_int(Param::GuaranteeE2ee, 1); // needed to pass `internet_access` requirements
|
||||
send_msg(self, chat_id, &mut msg).await?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user