From 18ee6cb0f24fab30efd1318e5c85565b8bb8e990 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Sat, 28 Sep 2024 13:21:10 -0400 Subject: [PATCH] Removal of "name" and "online", update libraries and rust --- auth/Cargo.toml | 8 +++--- client/Cargo.toml | 4 +-- server/Cargo.toml | 8 +++--- .../20240727041731_create_everything.sql | 2 -- server/src/server.rs | 27 ------------------- server/src/types.rs | 6 ----- 6 files changed, 10 insertions(+), 45 deletions(-) diff --git a/auth/Cargo.toml b/auth/Cargo.toml index cea3ec4..bde448f 100644 --- a/auth/Cargo.toml +++ b/auth/Cargo.toml @@ -4,16 +4,16 @@ version = "0.1.0" edition = "2021" [dependencies] -anyhow = "1.0.86" +anyhow = "1.0.89" futures = "0.3.30" tarpc = { version = "0.34.0", features = ["full"] } -tokio = { version = "1.39.1", features = ["macros", "net", "rt-multi-thread"] } +tokio = { version = "1.40.0", features = ["macros", "net", "rt-multi-thread"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -serde = { version = "1.0.204", features = ["derive"] } +serde = { version = "1.0.210", features = ["derive"] } chrono = { version = "0.4.38", features = ["serde"] } dotenvy = "0.15.7" -sqlx = { version = "0.8.0", features = [ "runtime-tokio", "tls-rustls", "sqlite", "macros", "migrate", "chrono" ] } +sqlx = { version = "0.8.2", features = [ "runtime-tokio", "tls-rustls", "sqlite", "macros", "migrate", "chrono" ] } sha3 = "0.10.8" hex = "0.4.3" rand = "0.8.5" diff --git a/client/Cargo.toml b/client/Cargo.toml index 63dce5f..8744f89 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" realm_auth = { path = "../auth" } realm_server = { path = "../server" } realm_shared = { path = "../shared" } -egui = "0.28" -eframe = { version = "0.28", default-features = false, features = [ +egui = "0.29" +eframe = { version = "0.29", default-features = false, features = [ "default_fonts", # Embed the default egui fonts. "glow", # Use the glow rendering backend. Alternative: "wgpu". "persistence", # Enable restoring app state when restarting the app. diff --git a/server/Cargo.toml b/server/Cargo.toml index d59f05c..d300ebc 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -4,16 +4,16 @@ version = "0.1.0" edition = "2021" [dependencies] -anyhow = "1.0.86" +anyhow = "1.0.89" futures = "0.3.30" tarpc = { version = "0.34.0", features = ["full"] } -tokio = { version = "1.39.1", features = ["macros", "net", "rt-multi-thread"] } +tokio = { version = "1.40.0", features = ["macros", "net", "rt-multi-thread"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -serde = { version = "1.0.204", features = ["derive"] } +serde = { version = "1.0.210", features = ["derive"] } emojis = "0.6.3" chrono = { version = "0.4.38", features = ["serde"] } -sqlx = { version = "0.8.0", features = [ "runtime-tokio", "tls-rustls", "sqlite", "chrono" ] } +sqlx = { version = "0.8.2", features = [ "runtime-tokio", "tls-rustls", "sqlite", "chrono" ] } dotenvy = "0.15.7" moka = { version = "0.12.8", features = ["future"] } futures-util = "0.3.30" diff --git a/server/migrations/20240727041731_create_everything.sql b/server/migrations/20240727041731_create_everything.sql index a50e8b9..7010f16 100644 --- a/server/migrations/20240727041731_create_everything.sql +++ b/server/migrations/20240727041731_create_everything.sql @@ -2,7 +2,6 @@ CREATE TABLE IF NOT EXISTS room ( id INTEGER PRIMARY KEY, roomid VARCHAR(255) NOT NULL, --- name VARCHAR(255) NOT NULL, admin_only_send BOOL NOT NULL, admin_only_view BOOL NOT NULL ); @@ -11,7 +10,6 @@ CREATE TABLE IF NOT EXISTS user ( id INTEGER PRIMARY KEY, userid VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, --- online BOOL NOT NULL, owner BOOL NOT NULL, admin BOOL NOT NULL ); diff --git a/server/src/server.rs b/server/src/server.rs index 3fb6701..7412318 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -33,8 +33,6 @@ const FETCH_MESSAGE: &str = "SELECT message.*, room.id AS 'room_id', room.roomid AS 'room_roomid', room.admin_only_send AS 'room_admin_only_send', room.admin_only_view AS 'room_admin_only_view', user.id AS 'user_id', user.userid AS 'user_userid', user.name AS 'user_name', user.owner AS 'user_owner', user.admin AS 'user_admin' FROM message INNER JOIN room ON message.room = room.id INNER JOIN user ON message.user = user.id WHERE room.admin_only_view = ? OR false"; -// room.name AS 'room_name', -// user.online AS 'user_online', impl RealmChatServer { pub fn new(server_id: String, socket: SocketAddr, db_pool: Pool, packet_manager: Arc>) -> RealmChatServer { @@ -441,15 +439,6 @@ impl RealmChat for RealmChatServer { self.inner_get_all_users().await } - // async fn get_online_users(self, _: Context) -> Result, ErrorCode> { - // let result = query_as!(User, "SELECT * FROM user WHERE online = true").fetch_all(&self.db_pool).await; - // - // match result { - // Ok(users) => Ok(users), - // Err(_) => Err(Error), - // } - // } - async fn create_room(self, _: Context, stoken: String, room: Room) -> Result { if !self.is_user_admin(&stoken).await { return Err(Unauthorized) @@ -497,22 +486,6 @@ impl RealmChat for RealmChatServer { Err(_) => Err(MalformedDBResponse) } } - - // async fn rename_room(self, _: Context, stoken: String, roomid: String, new_name: String) -> Result<(), ErrorCode> { - // if !self.is_user_admin(&stoken).await { - // return Err(Unauthorized) - // } - // - // let result = query!("UPDATE room SET name = ? WHERE roomid = ?", new_name, roomid).execute(&self.db_pool).await; - // - // match result { - // Ok(_) => { - // // TODO: tell everyone - // Ok(()) - // } - // Err(_) => Err(MalformedDBResponse) - // } - // } async fn promote_user(self, _: Context, stoken: String, userid: String) -> Result<(), ErrorCode> { if !self.is_user_owner(&stoken).await { diff --git a/server/src/types.rs b/server/src/types.rs index c119c48..f4411ff 100644 --- a/server/src/types.rs +++ b/server/src/types.rs @@ -29,10 +29,8 @@ pub trait RealmChat { async fn get_room(stoken: String, roomid: String) -> Result; async fn get_user(userid: String) -> Result; async fn get_users() -> Result, ErrorCode>; - // async fn get_online_users() -> Result, ErrorCode>; async fn create_room(stoken: String, room: Room) -> Result; async fn delete_room(stoken: String, roomid: String) -> Result<(), ErrorCode>; - // async fn rename_room(stoken: String, roomid: String, new_name: String) -> Result<(), ErrorCode>; async fn promote_user(stoken: String, userid: String) -> Result<(), ErrorCode>; async fn demote_user(stoken: String, userid: String) -> Result<(), ErrorCode>; async fn kick_user(stoken: String, userid: String) -> Result<(), ErrorCode>; @@ -75,14 +73,12 @@ impl FromRow<'_, SqliteRow> for Message { id: row.try_get("user_id")?, userid: row.try_get("user_userid")?, name: row.try_get("user_name")?, - // online: row.try_get("user_online")?, owner: row.try_get("user_owner")?, admin: row.try_get("user_admin")?, }, room: Room { id: row.try_get("room_id")?, roomid: row.try_get("room_roomid")?, - // name: row.try_get("room_name")?, admin_only_send: row.try_get("room_admin_only_send")?, admin_only_view: row.try_get("room_admin_only_view")?, }, @@ -156,7 +152,6 @@ pub struct User { pub id: i64, pub userid: String, pub name: String, - // pub online: bool, pub owner: bool, pub admin: bool, } @@ -165,7 +160,6 @@ pub struct User { pub struct Room { pub id: i64, pub roomid: String, - // pub name: String, pub admin_only_send: bool, pub admin_only_view: bool, }