Skip to content

Commit

Permalink
✨ Use the correct record order
Browse files Browse the repository at this point in the history
  • Loading branch information
malted committed Jan 21, 2024
1 parent 1ca5106 commit e50ffe1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ impl Team {
let client = reqwest::blocking::Client::new();

let res = client
.get(format!("https://api.airtable.com/v0/{app_id}/Current"))
.get(format!(
"https://api.airtable.com/v0/{app_id}/Current?view=Grid%20view"
))
.header(reqwest::header::AUTHORIZATION, format!("Bearer {token}"))
.send()
.unwrap()
Expand Down Expand Up @@ -153,13 +155,13 @@ fn get_team(team: &State<RwLock<Team>>) -> Json<Team> {
Json(team.read().clone())
}

#[post("/?<token..>", format = "json", data = "<input>")]
fn update_team(team: &State<RwLock<Team>>, input: Json<Value>, token: String) -> Json<String> {
#[post("/?<token..>")]
fn notify_team_change(team: &State<RwLock<Team>>, token: String) -> Json<String> {
if token != var("TEAM_SERVER_SECRET").expect("a token") {
return Json(String::from("invalid token"));
}

*team.write() = Team::from_raw_airtable(input.into_inner());
*team.write() = Team::fetch();
Json(String::from("success!"))
}

Expand All @@ -174,6 +176,6 @@ fn rocket() -> _ {
}

rocket::custom(config)
.mount("/", routes![get_team, update_team])
.mount("/", routes![get_team, notify_team_change])
.manage(RwLock::new(Team::fetch()))
}

0 comments on commit e50ffe1

Please sign in to comment.