Removed dead code and removed frivilous import alias
This commit is contained in:
parent
8a91d51dc6
commit
2c6cdf9282
@ -1,9 +1,6 @@
|
|||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use hyper::{Body, Response, StatusCode};
|
use mysql_async::{Conn, Pool, error::Error};
|
||||||
use hyper::header::{HeaderName, HeaderValue};
|
|
||||||
use mysql_async::{Conn, Pool, error::Error as MySqlError};
|
|
||||||
use mysql_async::prelude::{params, Queryable};
|
use mysql_async::prelude::{params, Queryable};
|
||||||
use serde_json::Value;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::db_types::{UBigInt, BigInt, Integer, VarChar};
|
use crate::db_types::{UBigInt, BigInt, Integer, VarChar};
|
||||||
@ -20,7 +17,7 @@ pub struct Member {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn insert_new_member(p: &Pool, name: VarChar, perms: u64) -> Result<Member, MySqlError> {
|
pub async fn insert_new_member(p: &Pool, name: VarChar, perms: u64) -> Result<Member, Error> {
|
||||||
use crate::auth::generate_secret;
|
use crate::auth::generate_secret;
|
||||||
|
|
||||||
let conn: Conn = p.get_conn().await?;
|
let conn: Conn = p.get_conn().await?;
|
||||||
@ -58,29 +55,3 @@ pub async fn insert_new_member(p: &Pool, name: VarChar, perms: u64) -> Result<Me
|
|||||||
permissions: perms
|
permissions: perms
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn general_new_user(p: &Pool, resp: &mut Response<Body>, params: Value) {
|
|
||||||
/*
|
|
||||||
* @name: string => desired default name
|
|
||||||
*/
|
|
||||||
use crate::perms;
|
|
||||||
let default_name = serde_json::json!("NewUser");
|
|
||||||
let name = params.get("name")
|
|
||||||
.unwrap_or(&default_name)
|
|
||||||
.as_str().unwrap_or("NewUser");
|
|
||||||
|
|
||||||
match insert_new_member(p, name.to_string(), perms::GENERAL_NEW).await {
|
|
||||||
Ok(new_member) => {
|
|
||||||
*resp.status_mut() = StatusCode::OK;
|
|
||||||
let json_hdr_name = HeaderName::from_static("Content-Type");
|
|
||||||
let json_hdr_val = HeaderValue::from_static("application/json");
|
|
||||||
resp.headers_mut().insert(json_hdr_name, json_hdr_val);
|
|
||||||
*resp.body_mut() = Body::from(serde_json::to_string(&new_member).unwrap());
|
|
||||||
},
|
|
||||||
Err(_) => {
|
|
||||||
*resp.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
|
||||||
*resp.body_mut() = Body::from("Could not process input");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user