Change joinuser, sendusermessage to use local_user_id
This commit is contained in:
parent
7c039340ed
commit
75a95acf04
3 changed files with 12 additions and 8 deletions
|
@ -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]
|
||||
|
|
|
@ -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<UserId, HashSet<ConnectionId>>,
|
||||
pub(super) user_rooms: HashMap<LocalUserId, HashSet<ConnectionId>>,
|
||||
|
||||
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<ConnectionId>,
|
||||
) -> Result<(), LemmyError>
|
||||
where
|
||||
|
|
|
@ -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<Response> {
|
|||
pub struct SendUserRoomMessage<Response> {
|
||||
pub op: UserOperation,
|
||||
pub response: Response,
|
||||
pub recipient_id: UserId,
|
||||
pub recipient_id: LocalUserId,
|
||||
pub websocket_id: Option<ConnectionId>,
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue