Removal of "name" and "online", update libraries and rust

This commit is contained in:
2024-09-28 13:21:10 -04:00
Unverified
parent c2ec816188
commit 18ee6cb0f2
6 changed files with 10 additions and 45 deletions

View File

@@ -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"

View File

@@ -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.

View File

@@ -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"

View File

@@ -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
);

View File

@@ -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<Sqlite>, packet_manager: Arc<Mutex<PacketManager>>) -> RealmChatServer {
@@ -441,15 +439,6 @@ impl RealmChat for RealmChatServer {
self.inner_get_all_users().await
}
// async fn get_online_users(self, _: Context) -> Result<Vec<User>, 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<Room, ErrorCode> {
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 {

View File

@@ -29,10 +29,8 @@ pub trait RealmChat {
async fn get_room(stoken: String, roomid: String) -> Result<Room, ErrorCode>;
async fn get_user(userid: String) -> Result<User, ErrorCode>;
async fn get_users() -> Result<Vec<User>, ErrorCode>;
// async fn get_online_users() -> Result<Vec<User>, ErrorCode>;
async fn create_room(stoken: String, room: Room) -> Result<Room, ErrorCode>;
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,
}