From: Dessalines Date: Fri, 12 Mar 2021 15:54:47 +0000 (-0500) Subject: Change joinuser, sendusermessage to use local_user_id X-Git-Url: http://these/git/%22%7Burl%7D/static/%7B%7D/%7B%60%24%7BrepoUrl%7D?a=commitdiff_plain;h=75a95acf0430966264c223d52af765a70d2a15dd;p=lemmy.git Change joinuser, sendusermessage to use local_user_id --- diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 5e76e8bc..373cacab 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -23,7 +23,7 @@ use thiserror::Error; pub type ConnectionId = usize; pub type PostId = i32; pub type CommunityId = i32; -pub type UserId = i32; +pub type LocalUserId = i32; pub type IpAddr = String; #[macro_export] diff --git a/crates/websocket/src/chat_server.rs b/crates/websocket/src/chat_server.rs index 9978d1ec..ea4a651a 100644 --- a/crates/websocket/src/chat_server.rs +++ b/crates/websocket/src/chat_server.rs @@ -15,8 +15,8 @@ use lemmy_utils::{ ConnectionId, IpAddr, LemmyError, + LocalUserId, PostId, - UserId, }; use rand::rngs::ThreadRng; use reqwest::Client; @@ -51,7 +51,7 @@ pub struct ChatServer { /// A map from user id to its connection ID for joined users. Remember a user can have multiple /// sessions (IE clients) - pub(super) user_rooms: HashMap>, + pub(super) user_rooms: HashMap>, pub(super) rng: ThreadRng, @@ -185,7 +185,11 @@ impl ChatServer { Ok(()) } - pub fn join_user_room(&mut self, user_id: UserId, id: ConnectionId) -> Result<(), LemmyError> { + pub fn join_user_room( + &mut self, + user_id: LocalUserId, + id: ConnectionId, + ) -> Result<(), LemmyError> { // remove session from all rooms for sessions in self.user_rooms.values_mut() { sessions.remove(&id); @@ -302,7 +306,7 @@ impl ChatServer { &self, op: &UserOperation, response: &Response, - recipient_id: UserId, + recipient_id: LocalUserId, websocket_id: Option, ) -> Result<(), LemmyError> where diff --git a/crates/websocket/src/messages.rs b/crates/websocket/src/messages.rs index b3d98d06..e66ffe11 100644 --- a/crates/websocket/src/messages.rs +++ b/crates/websocket/src/messages.rs @@ -1,7 +1,7 @@ use crate::UserOperation; use actix::{prelude::*, Recipient}; use lemmy_api_structs::{comment::CommentResponse, post::PostResponse}; -use lemmy_utils::{CommunityId, ConnectionId, IpAddr, PostId, UserId}; +use lemmy_utils::{CommunityId, ConnectionId, IpAddr, LocalUserId, PostId}; use serde::{Deserialize, Serialize}; /// Chat server sends this messages to session @@ -50,7 +50,7 @@ pub struct SendAllMessage { pub struct SendUserRoomMessage { pub op: UserOperation, pub response: Response, - pub recipient_id: UserId, + pub recipient_id: LocalUserId, pub websocket_id: Option, } @@ -91,7 +91,7 @@ pub struct SendComment { #[derive(Message)] #[rtype(result = "()")] pub struct JoinUserRoom { - pub local_user_id: UserId, + pub local_user_id: LocalUserId, pub id: ConnectionId, }