diff --git a/backend/src/bin/switchcounter_read.rs b/backend/src/bin/switchcounter_read.rs new file mode 100644 index 0000000..18f6bec --- /dev/null +++ b/backend/src/bin/switchcounter_read.rs @@ -0,0 +1,15 @@ +use color_eyre::eyre::Result; +use mi::web::SwitchCounter; +use std::env; + +fn main() -> Result<()> { + let whurl = env::args() + .skip(1) + .next() + .expect("usage: switchcounter_read "); + let cli = SwitchCounter::new(whurl); + let status = cli.status()?; + println!("{:?}", status); + + Ok(()) +} diff --git a/backend/src/web/switchcounter.rs b/backend/src/web/switchcounter.rs index cdd6e7b..1387e61 100644 --- a/backend/src/web/switchcounter.rs +++ b/backend/src/web/switchcounter.rs @@ -24,7 +24,7 @@ pub struct SwitchCommand { #[derive(Deserialize, Debug)] pub struct Status { pub member_name: String, - pub started_at: chrono::NaiveDateTime, + pub started_at: String, } pub struct Client { @@ -55,6 +55,7 @@ impl Client { let resp = ureq::post(&self.webhook_url).send_json(serde_json::to_value(Wrapper { webhook: FrontAsk::default(), })?); + if resp.ok() { Ok(resp.into_json_deserialize()?) } else {