parent
ee88cbeb55
commit
b0bc6f35c2
1 changed files with 14 additions and 11 deletions
|
@ -99,7 +99,7 @@ async fn update_ldap(config: &Config, db: &Pool<Sqlite>) {
|
||||||
impl From<&WolvesResultUser> for AccountWolves {
|
impl From<&WolvesResultUser> for AccountWolves {
|
||||||
fn from(input: &WolvesResultUser) -> Self {
|
fn from(input: &WolvesResultUser) -> Self {
|
||||||
AccountWolves {
|
AccountWolves {
|
||||||
id_wolves: input.wolves_id,
|
id_wolves: input.wolves_id.parse::<i64>().unwrap_or(0),
|
||||||
id_student: input.student_id.to_owned(),
|
id_student: input.student_id.to_owned(),
|
||||||
email: input.contact_email.to_owned(),
|
email: input.contact_email.to_owned(),
|
||||||
expiry: input.expiry.to_owned(),
|
expiry: input.expiry.to_owned(),
|
||||||
|
@ -112,7 +112,7 @@ impl From<&WolvesResultUser> for AccountWolves {
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
struct WolvesResultUser {
|
struct WolvesResultUser {
|
||||||
committee: String,
|
committee: String,
|
||||||
wolves_id: i64,
|
wolves_id: String,
|
||||||
first_name: String,
|
first_name: String,
|
||||||
last_name: String,
|
last_name: String,
|
||||||
contact_email: String,
|
contact_email: String,
|
||||||
|
@ -140,16 +140,19 @@ async fn get_wolves(config: &Config) -> Vec<AccountWolves> {
|
||||||
|
|
||||||
// get wolves data
|
// get wolves data
|
||||||
if let Ok(mut res) = surf::post(&config.wolves_url).header("X-AM-Identity", &config.wolves_key).await {
|
if let Ok(mut res) = surf::post(&config.wolves_url).header("X-AM-Identity", &config.wolves_key).await {
|
||||||
if let Ok(WolvesResult {
|
match res.body_json().await {
|
||||||
success,
|
Ok(WolvesResult {
|
||||||
result,
|
success,
|
||||||
}) = res.body_json().await
|
result,
|
||||||
{
|
}) => {
|
||||||
if success != 1 {
|
if success != 1 {
|
||||||
return vec![];
|
return vec![];
|
||||||
|
}
|
||||||
|
return result.iter().map(AccountWolves::from).collect::<Vec<AccountWolves>>();
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("{:?}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.iter().map(AccountWolves::from).collect::<Vec<AccountWolves>>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue