Skip to content

Commit

Permalink
fix: Rename room users to info
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 16, 2024
1 parent 6c1494c commit 7053ad0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub async fn handle(channel: &mut Channel, room: &Arc<Mutex<Room>>, json: &str)
"room::exit" => room::exit::handle(channel, room, &val).await,
"room::kick" => room::kick::handle(channel, room, &val).await,
"room::broadcast" => room::broadcast::handle(channel, room, &val).await,
"room::users" => room::users::handle(channel, room, &val).await,
"room::info" => room::info::handle(channel, room, &val).await,
"room::sync" => room::sync::handle(channel, room, &val).await,
"room::update_client" => room::update_client::handle(channel, room, &val).await,
"file::update" => file::update::handle(channel, room, &val).await,
Expand Down
7 changes: 4 additions & 3 deletions src/handler/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ pub mod update_client {
}

let path = data_str(json, "path");
let path = no_client_path(&client, &path);
let point = data_u64(json, "point");
let region_beg = data_u64(json, "region_beg");
let region_end = data_u64(json, "region_end");
Expand All @@ -301,17 +302,17 @@ pub mod update_client {
}
}

/// Room Users
/// Room Information
///
/// Return a list of users in room.
pub mod users {
pub mod info {
use crate::channel::*;
use crate::handler::room::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;

const METHOD: &str = "room::users";
const METHOD: &str = "room::info";

pub async fn handle(channel: &mut Channel, room: &Arc<Mutex<Room>>, json: &Value) {
let addr = &channel.get_connection().addr;
Expand Down
15 changes: 15 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::client::*;
use crate::room::*;
use crate::user::*;
use path_slash::PathBufExt as _;
Expand Down Expand Up @@ -107,6 +108,20 @@ pub fn no_room_path(room: &Room, path: &str) -> String {
path.replace(&room_path, "")
}

/// Remove client path.
///
/// # Arguments
///
/// * `room` - Room object.
/// * `path` - Path we want to remove room path.
pub fn no_client_path(client: &Client, path: &Option<String>) -> Option<String> {
if path.is_none() {
return None;
}
let path = path.clone().unwrap();
Some(path.replace(client.get_path(), ""))
}

/// Convert backslash to slash.
///
/// # Arguments
Expand Down

0 comments on commit 7053ad0

Please sign in to comment.