mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 05:46:29 +03:00
add source_code_url to manifest and get_webxdc_info, add a test (#3314)
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
### Changes
|
### Changes
|
||||||
- send normal messages with higher priority than MDNs #3243
|
- send normal messages with higher priority than MDNs #3243
|
||||||
- make Scheduler stateless #3302
|
- make Scheduler stateless #3302
|
||||||
|
- support `source_code_url` from Webxdc manifests #3314
|
||||||
|
|
||||||
### API-Changes
|
### API-Changes
|
||||||
- deprecate unused `marker1before` argument of `dc_get_chat_msgs`
|
- deprecate unused `marker1before` argument of `dc_get_chat_msgs`
|
||||||
|
|||||||
@@ -3731,6 +3731,10 @@ char* dc_msg_get_webxdc_blob (const dc_msg_t* msg, const char*
|
|||||||
* - summary: short string describing the state of the app,
|
* - summary: short string describing the state of the app,
|
||||||
* sth. as "2 votes", "Highscore: 123",
|
* sth. as "2 votes", "Highscore: 123",
|
||||||
* can be changed by the apps and defaults to an empty string.
|
* can be changed by the apps and defaults to an empty string.
|
||||||
|
* - source_code_url:
|
||||||
|
* URL where the source code of the Webxdc and other information can be found;
|
||||||
|
* defaults to an empty string.
|
||||||
|
* Implementations may offer an menu or a button to open this URL.
|
||||||
*
|
*
|
||||||
* @memberof dc_msg_t
|
* @memberof dc_msg_t
|
||||||
* @param msg The webxdc instance.
|
* @param msg The webxdc instance.
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const WEBXDC_RECEIVING_LIMIT: u64 = 4194304;
|
|||||||
struct WebxdcManifest {
|
struct WebxdcManifest {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
min_api: Option<u32>,
|
min_api: Option<u32>,
|
||||||
|
source_code_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parsed information from WebxdcManifest and fallbacks.
|
/// Parsed information from WebxdcManifest and fallbacks.
|
||||||
@@ -59,6 +60,7 @@ pub struct WebxdcInfo {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub icon: String,
|
pub icon: String,
|
||||||
pub summary: String,
|
pub summary: String,
|
||||||
|
pub source_code_url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Status Update ID.
|
/// Status Update ID.
|
||||||
@@ -538,12 +540,14 @@ impl Message {
|
|||||||
WebxdcManifest {
|
WebxdcManifest {
|
||||||
name: None,
|
name: None,
|
||||||
min_api: None,
|
min_api: None,
|
||||||
|
source_code_url: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WebxdcManifest {
|
WebxdcManifest {
|
||||||
name: None,
|
name: None,
|
||||||
min_api: None,
|
min_api: None,
|
||||||
|
source_code_url: None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -573,6 +577,11 @@ impl Message {
|
|||||||
.get(Param::WebxdcSummary)
|
.get(Param::WebxdcSummary)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
source_code_url: if let Some(url) = manifest.source_code_url {
|
||||||
|
url
|
||||||
|
} else {
|
||||||
|
"".to_string()
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1343,6 +1352,21 @@ sth_for_the = "future""#
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_parse_webxdc_manifest_source_code_url() -> Result<()> {
|
||||||
|
let result = parse_webxdc_manifest(r#"source_code_url = 3"#.as_bytes()).await;
|
||||||
|
assert!(result.is_err());
|
||||||
|
|
||||||
|
let manifest =
|
||||||
|
parse_webxdc_manifest(r#"source_code_url = "https://foo.bar""#.as_bytes()).await?;
|
||||||
|
assert_eq!(
|
||||||
|
manifest.source_code_url,
|
||||||
|
Some("https://foo.bar".to_string())
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_webxdc_min_api_too_large() -> Result<()> {
|
async fn test_webxdc_min_api_too_large() -> Result<()> {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user