aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2024-08-03 10:06:08 +0000
committerDaniel <kingdread@gmx.de>2024-08-03 10:06:08 +0000
commit3f0eb33c666afb2924eef835904fe48ef4503d2d (patch)
tree215f268e6ab227f9cdc59da3f6abfe93df6fd495 /src
parent99a05ae1e0d613c7b5c381fce26d4e2da0b560f3 (diff)
parent7267b44e9d32deb027d0822b6dd92e9c65614156 (diff)
downloadezau-3f0eb33c666afb2924eef835904fe48ef4503d2d.tar.gz
ezau-3f0eb33c666afb2924eef835904fe48ef4503d2d.tar.bz2
ezau-3f0eb33c666afb2924eef835904fe48ef4503d2d.zip
Merge branch 'enable-dps-report-url-configuration' into 'master'
feat: add dps.report upload url configuration See merge request dunj3/ezau!3
Diffstat (limited to 'src')
-rw-r--r--src/config.rs7
-rw-r--r--src/main.rs9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/config.rs b/src/config.rs
index 1c44aea..ad2ee22 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -9,6 +9,9 @@ use serde_with::{serde_as, OneOrMany};
pub struct Config {
/// Flag indicating whether logs should be uploaded or not.
pub upload: bool,
+ /// Where to upload the logs.
+ #[serde(default = "default_dps_report_upload_url")]
+ pub dps_report_upload_url: String,
/// Flag indicating whether logs with an unknown boss should be uploaded.
#[serde(default)]
pub upload_unknown: bool,
@@ -62,3 +65,7 @@ pub fn load<P: AsRef<Path>>(path: P) -> Result<Config> {
fn default_zip() -> bool {
true
}
+
+fn default_dps_report_upload_url() -> String {
+ String::from("https://dps.report/uploadContent")
+}
diff --git a/src/main.rs b/src/main.rs
index b86f281..6352bff 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,7 +27,6 @@ mod logbag;
#[cfg(feature = "im-matrix")]
mod matrix;
-const DPS_REPORT_API: &str = "https://dps.report/uploadContent";
const WATCH_DELAY_SECONDS: u64 = 2;
const RETRY_DELAY: Duration = Duration::from_secs(5);
@@ -83,7 +82,7 @@ fn inner_main(opts: &Opts) -> Result<()> {
match &opts.subcmd {
SubCommand::Watch(w) => watch(w, &config)?,
SubCommand::Upload(u) => {
- let permalink = upload_log(&u.path)?;
+ let permalink = upload_log(&u.path, &config.dps_report_upload_url)?;
println!("{}", permalink);
let log = load_log(&u.path)?;
@@ -181,7 +180,7 @@ fn handle_file(config: &Config, filename: &Path) -> Result<()> {
let mut try_counter = 0;
let permalink = loop {
- let result = upload_log(filename);
+ let result = upload_log(filename, &config.dps_report_upload_url);
if let Ok(link) = result {
break link;
}
@@ -238,7 +237,7 @@ fn load_log(path: &Path) -> Result<Log> {
evtclib::process_file(path, Compression::Zip).map_err(Into::into)
}
-fn upload_log(file: &Path) -> Result<String> {
+fn upload_log(file: &Path, url: &str) -> Result<String> {
#[derive(Debug, Deserialize)]
struct ApiResponse {
permalink: String,
@@ -248,7 +247,7 @@ fn upload_log(file: &Path) -> Result<String> {
let form = reqwest::blocking::multipart::Form::new().file("file", file)?;
let resp: ApiResponse = client
- .post(DPS_REPORT_API)
+ .post(url)
.query(&[("json", 1)])
.multipart(form)
.send()?