diff --git a/server/src/db.rs b/server/src/db.rs new file mode 100644 index 0000000..e42febe --- /dev/null +++ b/server/src/db.rs @@ -0,0 +1,58 @@ +/* Here we maintain all the different structures that we use to + * interface with our database at any given time + */ + +use diesel::prelude::SqliteConnection; + +enum UserType { + Native, + Remote, + Invalid, +} +#[table_name="users"] +#[derive(Serialize, Queryable, Insertable, Debug, Clone)] +struct User { + userid: String, + /* Sometimes this isn't a password persey + * Basically: native users and remote users will share this here but + * remote users are given a passkey which they don't control. + */ + passkey: String, + native: bool, + display: String, +} + +#[derive(FromForm)] +struct UserRegister{ + userid: String, + display: String, + passkey: String, // basically just a hash for now +} + +struct Ticket { + hashValue: String // probably just some huge text hash +} +impl User { + + /* only ever add a user to our database if they have a ticket whose id matches with + * a currently valid id + * This means that instances can be set to invite only if owners wish + */ + pub fn insert(user: UserLogin, entry: Ticket, conn: &SqliteConnection) -> bool { + } + + pub fn remove(userid: String) -> Result { + } + + pub fn get_user(userid: String) -> Result { + } + + pub fn update_display(userid: String) -> bool { + } + + pub fn update_passkey(userid: String, newpass_hash: String) -> bool { + } + + pub fn update_native(userid: String, newdisplay: String) -> bool { + } +}