Removal of "name" and "online", update libraries and rust
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user