feat: nixos side of the config #45

Merged
silver merged 5 commits from #20_wolves-api into main 2023-10-27 01:43:38 +00:00
Showing only changes of commit ba06d1ec0b - Show all commits

View file

@ -122,12 +122,12 @@ struct WolvesResultUser {
requested: String,
approved: String,
sitename: String,
domain: String
domain: String,
}
#[derive(Deserialize, Serialize, Debug)]
struct WolvesResult {
success: i8,
result: Vec<WolvesResultUser>
result: Vec<WolvesResultUser>,
}
async fn get_wolves(config: &Config) -> Vec<AccountWolves> {
@ -142,18 +142,21 @@ async fn get_wolves(config: &Config) -> Vec<AccountWolves> {
let uri = &config.wolves_url;
let mut res = surf::post(uri).header("X-AM-Identity", &config.wolves_key).await.unwrap();
if let Ok(WolvesResult { success, result }) = res.body_json().await {
if let Ok(WolvesResult {
success,
result,
}) = res.body_json().await
{
if success != 1 {
return vec![];
}
return result.iter().map(|wolves| AccountWolves::from(wolves) ).collect::<Vec<AccountWolves>>();
return result.iter().map(AccountWolves::from).collect::<Vec<AccountWolves>>();
}
vec![]
}
async fn update_account(db: &Pool<Sqlite>, account: &AccountWolves) {
sqlx::query_as::<_, AccountWolves>(
"