mirror of
https://github.com/chatmail/core.git
synced 2026-05-15 12:56:30 +03:00
cleanup checking xdc
This commit is contained in:
@@ -230,33 +230,19 @@ impl Context {
|
|||||||
bail!("{} is not a valid webxdc file", filename);
|
bail!("{} is not a valid webxdc file", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
let valid = match async_zip::read::fs::ZipFileReader::new(path).await {
|
let archive = async_zip::read::fs::ZipFileReader::new(path).await?;
|
||||||
Ok(archive) => {
|
if find_zip_entry(archive.file(), "index.html").is_none() {
|
||||||
if find_zip_entry(archive.file(), "index.html").is_none() {
|
bail!("{} misses index.html", filename);
|
||||||
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
|
if let Ok(bytes) = get_blob(&archive, "manifest.toml").await {
|
||||||
|
let manifest = parse_webxdc_manifest(&bytes)?;
|
||||||
|
if let Some(integration) = manifest.integration {
|
||||||
|
if integration == "maps" && msg.chat_id.is_self_talk(&self).await? {
|
||||||
|
info!(self, "{} set as maps integration", filename);
|
||||||
|
msg.param.set_int(Param::WebxdcIntegration, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
|
||||||
warn!(self, "{} cannot be opened as zip-file", filename);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if !valid {
|
|
||||||
bail!("{} is not a valid webxdc file", filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user