diff --git a/src/methods/discord.rs b/src/methods/discord.rs index 1c32e78..ab01daf 100644 --- a/src/methods/discord.rs +++ b/src/methods/discord.rs @@ -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) -> Vec { + pub async fn get_discord_users(db: &Pool) -> Vec { 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); + } } }