From dc142e8521a2e18a6d839b5d4d1e356d57f43a90 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 11 Sep 2023 01:06:17 +0100 Subject: [PATCH] fix: return the wolves id as well --- src/methods/discord.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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); + } } }