From: Dessalines Date: Mon, 8 Apr 2019 22:10:38 +0000 (-0700) Subject: Hiding some print messages, removing unused code. X-Git-Url: http://these/git/%24%7Bk%5B1%5D.custom_emoji.image_url%7D?a=commitdiff_plain;h=ee03b5a55f07ff396571dd6ed47a839a5446aac9;p=lemmy.git Hiding some print messages, removing unused code. --- diff --git a/server/src/bin/main.rs b/server/src/bin/main.rs index ed1c86fe..96f8181d 100644 --- a/server/src/bin/main.rs +++ b/server/src/bin/main.rs @@ -82,11 +82,12 @@ impl Actor for WSSession { } /// Handle messages from chat server, we simply send it to peer websocket +/// These are room messages, IE sent to others in the room impl Handler for WSSession { type Result = (); fn handle(&mut self, msg: WSMessage, ctx: &mut Self::Context) { - println!("id: {} msg: {}", self.id, msg.0); + // println!("id: {} msg: {}", self.id, msg.0); ctx.text(msg.0); } } @@ -94,7 +95,7 @@ impl Handler for WSSession { /// WebSocket message handler impl StreamHandler for WSSession { fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) { - println!("WEBSOCKET MESSAGE: {:?} from id: {}", msg, self.id); + // println!("WEBSOCKET MESSAGE: {:?} from id: {}", msg, self.id); match msg { ws::Message::Ping(msg) => { self.hb = Instant::now(); diff --git a/server/src/websocket_server/server.rs b/server/src/websocket_server/server.rs index e116fadc..92542d0a 100644 --- a/server/src/websocket_server/server.rs +++ b/server/src/websocket_server/server.rs @@ -328,16 +328,6 @@ impl ChatServer { } } } - - // /// Send message only to self - // fn send(&self, message: &str, id: &usize) { - // // println!("{:?}", self.sessions); - // if let Some(addr) = self.sessions.get(id) { - // println!("msg: {}", message); - // // println!("{:?}", addr.connected()); - // let _ = addr.do_send(WSMessage(message.to_owned())); - // } - // } } /// Make actor from `ChatServer` @@ -389,22 +379,9 @@ impl Handler for ChatServer { } } } - // send message to other users - // for room in rooms { - // self.send_room_message(room, "Someone disconnected", 0); - // } } } -/// Handler for Message message. -// impl Handler for ChatServer { -// type Result = (); - -// fn handle(&mut self, msg: ClientMessage, _: &mut Context) { -// self.send_room_message(&msg.room, msg.msg.as_str(), msg.id); -// } -// } - /// Handler for Message message. impl Handler for ChatServer { type Result = MessageResult; @@ -800,8 +777,6 @@ impl Perform for GetPost { let conn = establish_connection(); - println!("{:?}", self.auth); - let user_id: Option = match &self.auth { Some(auth) => { match Claims::decode(&auth) { @@ -1141,7 +1116,6 @@ impl Perform for GetPosts { let posts = match PostView::list(&conn, type_, &sort, self.community_id, None, user_id, self.limit) { Ok(posts) => posts, Err(_e) => { - eprintln!("{}", _e); return self.error("Couldn't get posts"); } }; @@ -1486,185 +1460,3 @@ impl Perform for GetUserDetails { } } -// impl Handler for ChatServer { - -// type Result = MessageResult; -// fn handle(&mut self, msg: Login, _: &mut Context) -> Self::Result { - -// let conn = establish_connection(); - -// // Fetch that username / email -// let user: User_ = match User_::find_by_email_or_username(&conn, &msg.username_or_email) { -// Ok(user) => user, -// Err(_e) => return MessageResult( -// Err( -// ErrorMessage { -// op: UserOperation::Login.to_string(), -// error: "Couldn't find that username or email".to_string() -// } -// ) -// ) -// }; - -// // Verify the password -// let valid: bool = verify(&msg.password, &user.password_encrypted).unwrap_or(false); -// if !valid { -// return MessageResult( -// Err( -// ErrorMessage { -// op: UserOperation::Login.to_string(), -// error: "Password incorrect".to_string() -// } -// ) -// ) -// } - -// // Return the jwt -// MessageResult( -// Ok( -// LoginResponse { -// op: UserOperation::Login.to_string(), -// jwt: user.jwt() -// } -// ) -// ) -// } -// } - -// impl Handler for ChatServer { - -// type Result = MessageResult; -// fn handle(&mut self, msg: Register, _: &mut Context) -> Self::Result { - -// let conn = establish_connection(); - -// // Make sure passwords match -// if msg.password != msg.password_verify { -// return MessageResult( -// Err( -// ErrorMessage { -// op: UserOperation::Register.to_string(), -// error: "Passwords do not match.".to_string() -// } -// ) -// ); -// } - -// // Register the new user -// let user_form = UserForm { -// name: msg.username, -// email: msg.email, -// password_encrypted: msg.password, -// preferred_username: None, -// updated: None -// }; - -// // Create the user -// let inserted_user = match User_::create(&conn, &user_form) { -// Ok(user) => user, -// Err(_e) => return MessageResult( -// Err( -// ErrorMessage { -// op: UserOperation::Register.to_string(), -// error: "User already exists.".to_string() // overwrite the diesel error -// } -// ) -// ) -// }; - -// // Return the jwt -// MessageResult( -// Ok( -// LoginResponse { -// op: UserOperation::Register.to_string(), -// jwt: inserted_user.jwt() -// } -// ) -// ) - -// } -// } - - -// impl Handler for ChatServer { - -// type Result = MessageResult; - -// fn handle(&mut self, msg: CreateCommunity, _: &mut Context) -> Self::Result { -// let conn = establish_connection(); - -// let user_id = Claims::decode(&msg.auth).id; - -// let community_form = CommunityForm { -// name: msg.name, -// updated: None -// }; - -// let community = match Community::create(&conn, &community_form) { -// Ok(community) => community, -// Err(_e) => return MessageResult( -// Err( -// ErrorMessage { -// op: UserOperation::CreateCommunity.to_string(), -// error: "Community already exists.".to_string() // overwrite the diesel error -// } -// ) -// ) -// }; - -// MessageResult( -// Ok( -// CommunityResponse { -// op: UserOperation::CreateCommunity.to_string(), -// community: community -// } -// ) -// ) -// } -// } -// -// -// -// /// Handler for `ListRooms` message. -// impl Handler for ChatServer { -// type Result = MessageResult; - -// fn handle(&mut self, _: ListRooms, _: &mut Context) -> Self::Result { -// let mut rooms = Vec::new(); - -// for key in self.rooms.keys() { -// rooms.push(key.to_owned()) -// } - -// MessageResult(rooms) -// } -// } - -// /// Join room, send disconnect message to old room -// /// send join message to new room -// impl Handler for ChatServer { -// type Result = (); - -// fn handle(&mut self, msg: Join, _: &mut Context) { -// let Join { id, name } = msg; -// let mut rooms = Vec::new(); - -// // remove session from all rooms -// for (n, sessions) in &mut self.rooms { -// if sessions.remove(&id) { -// rooms.push(n.to_owned()); -// } -// } -// // send message to other users -// for room in rooms { -// self.send_room_message(&room, "Someone disconnected", 0); -// } - -// if self.rooms.get_mut(&name).is_none() { -// self.rooms.insert(name.clone(), HashSet::new()); -// } -// self.send_room_message(&name, "Someone connected", id); -// self.rooms.get_mut(&name).unwrap().insert(id); -// } - -// }