const CONTRIBUTE_ENDPOINT: &str = "https://vastlint.org/api/samples";
pub fn submit(xml: String, version: Option<String>, errors: usize, warnings: usize, infos: usize) {
if CONTRIBUTE_ENDPOINT.is_empty() {
return;
}
let version_json = match version {
Some(v) => format!("\"{}\"", crate::json_escape(&v)),
None => "null".to_owned(),
};
let body = format!(
"{{\"xml\":\"{}\",\"source\":\"cli\",\"version\":{},\"summary\":{{\"errors\":{},\"warnings\":{},\"infos\":{}}}}}",
crate::json_escape(&xml),
version_json,
errors,
warnings,
infos,
);
std::thread::spawn(move || {
let _ = ureq::post(CONTRIBUTE_ENDPOINT)
.set("Content-Type", "application/json")
.timeout(std::time::Duration::from_secs(5))
.send_string(&body);
});
}