fix: return the wolves id as well
This commit is contained in:
parent
7af2f92f22
commit
dc142e8521
1 changed files with 14 additions and 6 deletions
|
@ -7,6 +7,7 @@ use tide::{
|
||||||
|
|
||||||
pub mod account {
|
pub mod account {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::methods::account_new::email::get_wolves_mail;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
@ -26,7 +27,7 @@ pub mod account {
|
||||||
|
|
||||||
let db = &req.state().db;
|
let db = &req.state().db;
|
||||||
|
|
||||||
let result = get_wolves_mail(db).await;
|
let result = get_discord_users(db).await;
|
||||||
|
|
||||||
Ok(json!(result).into())
|
Ok(json!(result).into())
|
||||||
}
|
}
|
||||||
|
@ -35,9 +36,10 @@ pub mod account {
|
||||||
pub struct DiscordResult {
|
pub struct DiscordResult {
|
||||||
discord: String,
|
discord: String,
|
||||||
email: 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>(
|
let results = sqlx::query_as::<_, Accounts>(
|
||||||
r#"
|
r#"
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -53,10 +55,16 @@ pub mod account {
|
||||||
|
|
||||||
for item in results {
|
for item in results {
|
||||||
if let Some(discord) = item.discord {
|
if let Some(discord) = item.discord {
|
||||||
result.push(DiscordResult {
|
let accounts = get_wolves_mail(db, &item.mail).await;
|
||||||
discord,
|
if !accounts.is_empty() {
|
||||||
email: item.mail,
|
let tmp = DiscordResult {
|
||||||
});
|
discord,
|
||||||
|
email: item.mail,
|
||||||
|
wolves_id: accounts[0].id_wolves.to_owned(),
|
||||||
|
};
|
||||||
|
|
||||||
|
result.push(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue