fix: return the wolves id as well

This commit is contained in:
silver 2023-09-11 01:06:17 +01:00
parent 7af2f92f22
commit dc142e8521

View file

@ -7,6 +7,7 @@ use tide::{
pub mod account {
use super::*;
use crate::methods::account_new::email::get_wolves_mail;
use serde::Serialize;
#[derive(Debug, Deserialize)]
@ -26,7 +27,7 @@ pub mod account {
let db = &req.state().db;
let result = get_wolves_mail(db).await;
let result = get_discord_users(db).await;
Ok(json!(result).into())
}
@ -35,9 +36,10 @@ pub mod account {
pub struct DiscordResult {
discord: String,
email: String,
wolves_id: String,
}
pub async fn get_wolves_mail(db: &Pool<Sqlite>) -> Vec<DiscordResult> {
pub async fn get_discord_users(db: &Pool<Sqlite>) -> Vec<DiscordResult> {
let results = sqlx::query_as::<_, Accounts>(
r#"
SELECT *
@ -53,10 +55,16 @@ pub mod account {
for item in results {
if let Some(discord) = item.discord {
result.push(DiscordResult {
discord,
email: item.mail,
});
let accounts = get_wolves_mail(db, &item.mail).await;
if !accounts.is_empty() {
let tmp = DiscordResult {
discord,
email: item.mail,
wolves_id: accounts[0].id_wolves.to_owned(),
};
result.push(tmp);
}
}
}