From 92fad0dc4bd936802d3324bcb43790530b6212db Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 27 Aug 2023 20:33:43 +0100 Subject: [PATCH] feat: added a route to return discord usernames. Closes #19 --- Cargo.lock | 369 +++++++++++++++++++++++----------- Cargo.toml | 2 +- flake.nix | 18 +- src/lib.rs | 5 + src/main.rs | 5 +- src/methods/account_update.rs | 19 +- src/methods/discord.rs | 55 +++++ src/methods/mod.rs | 1 + 8 files changed, 352 insertions(+), 122 deletions(-) create mode 100644 src/methods/discord.rs diff --git a/Cargo.lock b/Cargo.lock index 8ee6a84..3338b6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,17 +56,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.9", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.3" @@ -74,6 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if 1.0.0", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -216,18 +206,6 @@ dependencies = [ "event-listener", ] -[[package]] -name = "async-native-tls" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57d4cec3c647232e1094dc013546c0b33ce785d8aeb251e1f20dfaf8a9a13fe" -dependencies = [ - "futures-util", - "native-tls", - "thiserror", - "url", -] - [[package]] name = "async-process" version = "1.7.0" @@ -328,9 +306,9 @@ dependencies = [ [[package]] name = "atoi" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] @@ -398,6 +376,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] + [[package]] name = "blake3" version = "0.3.8" @@ -558,7 +545,7 @@ checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" dependencies = [ "aes-gcm", "base64 0.13.1", - "hkdf", + "hkdf 0.10.0", "hmac 0.10.1", "percent-encoding", "rand 0.8.5", @@ -779,6 +766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -870,6 +858,9 @@ name = "either" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +dependencies = [ + "serde", +] [[package]] name = "elliptic-curve" @@ -915,6 +906,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "erased-serde" version = "0.3.25" @@ -945,6 +942,17 @@ dependencies = [ "libc", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if 1.0.0", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -1089,9 +1097,9 @@ dependencies = [ [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", @@ -1226,21 +1234,21 @@ dependencies = [ "subtle", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "hashlink" version = "0.8.2" @@ -1281,6 +1289,15 @@ dependencies = [ "hmac 0.10.1", ] +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac 0.12.1", +] + [[package]] name = "hmac" version = "0.8.1" @@ -1310,6 +1327,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -1415,12 +1441,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -1604,9 +1630,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.24.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" dependencies = [ "cc", "pkg-config", @@ -1680,6 +1706,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "md-5" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "memchr" version = "2.5.0" @@ -1814,7 +1849,7 @@ version = "0.10.52" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "foreign-types", "libc", @@ -1884,27 +1919,25 @@ checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.6" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if 1.0.0", - "instant", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", - "winapi", + "windows-targets 0.48.0", ] [[package]] @@ -2006,7 +2039,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "concurrent-queue", "libc", @@ -2166,22 +2199,13 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - [[package]] name = "redox_syscall" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2247,7 +2271,7 @@ version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -2296,7 +2320,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -2587,23 +2611,27 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.6.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +checksum = "8e58421b6bc416714d5115a2ca953718f6c621a51b68e4f4922aea5a4391a721" dependencies = [ "sqlx-core", "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", ] [[package]] name = "sqlx-core" -version = "0.6.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53" dependencies = [ - "ahash 0.7.6", + "ahash", + "async-io", + "async-std", "atoi", - "bitflags", "byteorder", "bytes 1.4.0", "crc", @@ -2611,62 +2639,171 @@ dependencies = [ "dotenvy", "either", "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap", + "log", + "memchr", + "native-tls", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2 0.10.7", + "smallvec", + "sqlformat", + "thiserror", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "208e3165167afd7f3881b16c1ef3f2af69fa75980897aac8874a0696516d12c2" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a4a8336d278c62231d87f24e8a7a74898156e34c1c18942857be2acb29c7dfc" +dependencies = [ + "async-std", + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.10.7", + "sqlx-core", + "sqlx-mysql", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482" +dependencies = [ + "atoi", + "base64 0.21.2", + "bitflags 2.4.0", + "byteorder", + "bytes 1.4.0", + "crc", + "digest 0.10.7", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf 0.12.3", + "hmac 0.12.1", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "serde", + "sha1 0.10.5", + "sha2 0.10.7", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e" +dependencies = [ + "atoi", + "base64 0.21.2", + "bitflags 2.4.0", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf 0.12.3", + "hmac 0.12.1", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand 0.8.5", + "serde", + "serde_json", + "sha1 0.10.5", + "sha2 0.10.7", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4c21bf34c7cae5b283efb3ac1bcc7670df7561124dc2f8bdc0b59be40f79a2" +dependencies = [ + "atoi", "flume 0.10.14", "futures-channel", "futures-core", "futures-executor", "futures-intrusive", "futures-util", - "hashlink", - "hex", - "indexmap", - "itoa", - "libc", "libsqlite3-sys", "log", - "memchr", - "once_cell", - "paste", "percent-encoding", - "sha2 0.10.7", - "smallvec", - "sqlformat", - "sqlx-rt", - "stringprep", - "thiserror", - "url", -] - -[[package]] -name = "sqlx-macros" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" -dependencies = [ - "dotenvy", - "either", - "heck", - "once_cell", - "proc-macro2", - "quote", - "sha2 0.10.7", + "serde", "sqlx-core", - "sqlx-rt", - "syn 1.0.109", + "tracing", "url", ] -[[package]] -name = "sqlx-rt" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" -dependencies = [ - "async-native-tls", - "async-std", - "native-tls", -] - [[package]] name = "ssh-cipher" version = "0.2.0" @@ -2847,7 +2984,7 @@ checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if 1.0.0", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall", "rustix", "windows-sys 0.45.0", ] @@ -3262,6 +3399,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "whoami" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 7556d3b..5a3f833 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ async-std = { version = "1.12.0", features = ["attributes"] } serde = { version = "1.0", features = ["derive"] } # For sqlite -sqlx = { version = "0.6.3", features = [ "runtime-async-std-native-tls", "sqlite" ] } +sqlx = { version = "0.7.1", features = [ "runtime-async-std-native-tls", "sqlite" ] } # to make the http requests surf = "2.3.2" diff --git a/flake.nix b/flake.nix index 01a08ae..c3f0830 100644 --- a/flake.nix +++ b/flake.nix @@ -114,9 +114,15 @@ enable = mkEnableOption "enable ${package_name}"; # keep really secret stuff in this - envFile = mkOption rec { - type = types.str; - description = "The env file"; + env = { + ldap = mkOption rec { + type = types.str; + description = "Auth for the LDAP, has LDAP_ADMIN_PW"; + }; + discord = mkOption rec { + type = types.str; + description = "Auth for the discord bot, has LDAP_DISCORD_AUTH"; + }; }; ldap = { @@ -222,7 +228,11 @@ Group = "${cfg.user}"; Restart = "always"; ExecStart = "${self.defaultPackage."${system}"}/bin/${package_name}"; - EnvironmentFile = "${cfg.envFile}"; + # multiple files + EnvironmentFile = [ + "${cfg.env.ldap}" + "${cfg.env.discord}" + ]; }; }; } // serviceGenerator scripts; diff --git a/src/lib.rs b/src/lib.rs index cdc98a5..3647826 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,6 +189,7 @@ pub struct Config { pub mail_user: String, pub mail_pass: String, pub ssh_root: String, + pub auth_discord: String, } pub fn get_config() -> Config { @@ -207,6 +208,7 @@ pub fn get_config() -> Config { mail_user: "".to_string(), mail_pass: "".to_string(), ssh_root: "skynet_old".to_string(), + auth_discord: "".to_string(), }; if let Ok(x) = env::var("LDAP_HOST") { @@ -242,6 +244,9 @@ pub fn get_config() -> Config { if let Ok(x) = env::var("SSH_ROOT") { config.ssh_root = x.trim().to_string(); } + if let Ok(x) = env::var("LDAP_DISCORD_AUTH") { + config.auth_discord = x.trim().to_string(); + } config } diff --git a/src/main.rs b/src/main.rs index 262d918..a038760 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use skynet_ldap_backend::{ db_init, get_config, - methods::{account_new, account_recover, account_update}, + methods::{account_new, account_recover, account_update, discord}, State, }; @@ -34,6 +34,9 @@ async fn main() -> tide::Result<()> { app.at("/ldap/recover/ssh/request").post(account_recover::ssh::request); app.at("/ldap/recover/ssh/verify").post(account_recover::ssh::verify); + // for discord + app.at("/ldap/discord").get(discord::account::get); + app.listen(host_port).await?; Ok(()) } diff --git a/src/methods/account_update.rs b/src/methods/account_update.rs index a0c2f56..e53ebe0 100644 --- a/src/methods/account_update.rs +++ b/src/methods/account_update.rs @@ -1,4 +1,4 @@ -use crate::{methods::account_new::email::get_wolves_mail, update_group, Config, State}; +use crate::{methods::account_new::email::get_wolves_mail, update_group, Accounts, Config, State}; use ldap3::{exop::PasswordModify, LdapConn, Mod, Scope, SearchEntry}; use sqlx::{Pool, Sqlite}; use std::collections::{HashMap, HashSet}; @@ -77,7 +77,7 @@ pub async fn submit(mut req: Request) -> tide::Result { // if password is not being updated then just update the required field let mods = vec![ // the value we are updating - Mod::Replace(field, HashSet::from([value])), + Mod::Replace(field.clone(), HashSet::from([value.clone()])), ]; ldap.modify(&dn, mods)?.success()?; @@ -88,7 +88,7 @@ pub async fn submit(mut req: Request) -> tide::Result { } else { // password is going to be updated, even if the old value is not starting with "{SSHA512}" pw_keep_same = false; - value + value.clone() }; // changing teh password because of an explicit request or upgrading teh security. @@ -108,6 +108,14 @@ pub async fn submit(mut req: Request) -> tide::Result { ldap.unbind()?; + // if its mail or discord update the local db + if &field == "skDiscord" { + update_local_db(db, "discord", &value).await.ok(); + } + if &field == "mail" { + update_local_db(db, "mail", &value).await.ok(); + } + Ok(json!({"result": "success", "success": result}).into()) } @@ -152,3 +160,8 @@ async fn activate_group(db: &Pool, config: &Config, user: &str, mail: &s } } } + +async fn update_local_db(db: &Pool, field: &str, value: &str) -> Result, sqlx::Error> { + let query = format!("INSERT OR REPLACE INTO accounts ({field}) VALUES (?1)"); + sqlx::query_as::<_, Accounts>(&query).bind(value.to_owned()).fetch_optional(db).await +} diff --git a/src/methods/discord.rs b/src/methods/discord.rs new file mode 100644 index 0000000..a8f7648 --- /dev/null +++ b/src/methods/discord.rs @@ -0,0 +1,55 @@ +use crate::{Accounts, State}; +use sqlx::{Pool, Sqlite}; +use tide::{ + prelude::{json, Deserialize}, + Request, +}; + +pub mod account { + use super::*; + + #[derive(Debug, Deserialize)] + struct Auth { + auth: String, + } + pub async fn get(req: Request) -> tide::Result { + let config = &req.state().config; + + if let Ok(auth) = req.query::() { + if auth.auth != config.auth_discord { + return Ok(json!([]).into()); + } + } else { + return Ok(json!([]).into()); + }; + + let db = &req.state().db; + + let result = get_wolves_mail(db).await; + + Ok(json!(result).into()) + } + + pub async fn get_wolves_mail(db: &Pool) -> Vec { + let results = sqlx::query_as::<_, Accounts>( + r#" + SELECT * + FROM accounts + WHERE discord IS NOT NULL AND enabled = 1 + "#, + ) + .fetch_all(db) + .await + .unwrap_or(vec![]); + + let mut result = vec![]; + + for item in results { + if let Some(discord) = item.discord { + result.push(discord); + } + } + + result + } +} diff --git a/src/methods/mod.rs b/src/methods/mod.rs index 8273b7b..2f22b18 100644 --- a/src/methods/mod.rs +++ b/src/methods/mod.rs @@ -1,3 +1,4 @@ pub mod account_new; pub mod account_recover; pub mod account_update; +pub mod discord;