poc for insertion of new users
This commit is contained in:
parent
898fcf9ba8
commit
ef7eca3462
@ -28,6 +28,7 @@ mod members;
|
||||
mod messages;
|
||||
mod badges;
|
||||
mod http_params;
|
||||
mod perms;
|
||||
|
||||
|
||||
async fn route_dispatcher(pool: &Pool, resp: &mut Response<Body>, meth: &Method, path: &str, params: serde_json::Value) {
|
||||
|
@ -1,7 +1,48 @@
|
||||
use mysql_async::{Pool, Conn};
|
||||
use crate::badges::Badge;
|
||||
use crate::err::DbError;
|
||||
|
||||
pub struct Member {
|
||||
id: u64,
|
||||
name: String,
|
||||
permissions: u64,
|
||||
badges: Vec<Badge>,
|
||||
badges: Option<Vec<Badge>>,
|
||||
}
|
||||
|
||||
struct InsertableMember<'n> {
|
||||
name: &'n str,
|
||||
permissions: u64,
|
||||
badges: Option<Vec<Badge>>
|
||||
}
|
||||
|
||||
async fn insert_new_member<'nm>(conn: &Conn, name: &'nm str)
|
||||
-> Result<Member, DbError<'nm>> {
|
||||
// Updates both the members and keys table accordingly
|
||||
use crate::perms::{JOIN_VOICE, SEND_MESSAGES};
|
||||
let m = InsertableMember {
|
||||
name: name,
|
||||
permissions: JOIN_VOICE | SEND_MESSAGES, // can join voice and send messages by default
|
||||
badges: None
|
||||
};
|
||||
// TODO: this stuff once the invites/ user generation to be done
|
||||
// conn.batch_exec(
|
||||
// r"INSERT INTO `members` (name, status)",
|
||||
// params!{
|
||||
// "name" => name,
|
||||
// "join"
|
||||
// }
|
||||
// ).await;
|
||||
Err(DbError::from("Could not create user"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod members_tests {
|
||||
use mysql_async::{Pool, Conn};
|
||||
use std::env::var;
|
||||
use dotenv::dotenv;
|
||||
#[test]
|
||||
fn db_create_member() {
|
||||
let conn = Pool::new(&var("DATABASE_URL").unwrap()).get_conn();
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user