-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide whitelist information on
/Whitelist
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use rocket::serde::json::Json; | ||
use rocket_db_pools::Connection; | ||
use serde::Serialize; | ||
use sqlx::{prelude::FromRow, query_as}; | ||
|
||
use crate::Cmdb; | ||
|
||
#[derive(Serialize, FromRow)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct WhitelistPlayer { | ||
id: i64, | ||
ckey: Option<String>, | ||
whitelist_status: Option<String>, | ||
} | ||
|
||
#[get("/")] | ||
pub async fn get_all_whitelistees(mut db: Connection<Cmdb>) -> Json<Vec<WhitelistPlayer>> { | ||
match query_as( | ||
"SELECT id, ckey, whitelist_status FROM players WHERE (whitelist_status is not null AND LENGTH(whitelist_status) > 0)", | ||
) | ||
.fetch_all(&mut **db) | ||
.await | ||
{ | ||
Ok(result) => Json(result), | ||
Err(_) => Json(Vec::new()), | ||
} | ||
} |