mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 06:11:26 +00:00
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 ConnectionId = usize;
|
||||||
pub type PostId = i32;
|
pub type PostId = i32;
|
||||||
pub type CommunityId = i32;
|
pub type CommunityId = i32;
|
||||||
pub type UserId = i32;
|
pub type LocalUserId = i32;
|
||||||
pub type IpAddr = String;
|
pub type IpAddr = String;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
|
@ -15,8 +15,8 @@ use lemmy_utils::{
|
||||||
ConnectionId,
|
ConnectionId,
|
||||||
IpAddr,
|
IpAddr,
|
||||||
LemmyError,
|
LemmyError,
|
||||||
|
LocalUserId,
|
||||||
PostId,
|
PostId,
|
||||||
UserId,
|
|
||||||
};
|
};
|
||||||
use rand::rngs::ThreadRng;
|
use rand::rngs::ThreadRng;
|
||||||
use reqwest::Client;
|
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
|
/// A map from user id to its connection ID for joined users. Remember a user can have multiple
|
||||||
/// sessions (IE clients)
|
/// sessions (IE clients)
|
||||||
pub(super) user_rooms: HashMap<UserId, HashSet<ConnectionId>>,
|
pub(super) user_rooms: HashMap<LocalUserId, HashSet<ConnectionId>>,
|
||||||
|
|
||||||
pub(super) rng: ThreadRng,
|
pub(super) rng: ThreadRng,
|
||||||
|
|
||||||
|
@ -185,7 +185,11 @@ impl ChatServer {
|
||||||
Ok(())
|
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
|
// remove session from all rooms
|
||||||
for sessions in self.user_rooms.values_mut() {
|
for sessions in self.user_rooms.values_mut() {
|
||||||
sessions.remove(&id);
|
sessions.remove(&id);
|
||||||
|
@ -302,7 +306,7 @@ impl ChatServer {
|
||||||
&self,
|
&self,
|
||||||
op: &UserOperation,
|
op: &UserOperation,
|
||||||
response: &Response,
|
response: &Response,
|
||||||
recipient_id: UserId,
|
recipient_id: LocalUserId,
|
||||||
websocket_id: Option<ConnectionId>,
|
websocket_id: Option<ConnectionId>,
|
||||||
) -> Result<(), LemmyError>
|
) -> Result<(), LemmyError>
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::UserOperation;
|
use crate::UserOperation;
|
||||||
use actix::{prelude::*, Recipient};
|
use actix::{prelude::*, Recipient};
|
||||||
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
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};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Chat server sends this messages to session
|
/// Chat server sends this messages to session
|
||||||
|
@ -50,7 +50,7 @@ pub struct SendAllMessage<Response> {
|
||||||
pub struct SendUserRoomMessage<Response> {
|
pub struct SendUserRoomMessage<Response> {
|
||||||
pub op: UserOperation,
|
pub op: UserOperation,
|
||||||
pub response: Response,
|
pub response: Response,
|
||||||
pub recipient_id: UserId,
|
pub recipient_id: LocalUserId,
|
||||||
pub websocket_id: Option<ConnectionId>,
|
pub websocket_id: Option<ConnectionId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ pub struct SendComment {
|
||||||
#[derive(Message)]
|
#[derive(Message)]
|
||||||
#[rtype(result = "()")]
|
#[rtype(result = "()")]
|
||||||
pub struct JoinUserRoom {
|
pub struct JoinUserRoom {
|
||||||
pub local_user_id: UserId,
|
pub local_user_id: LocalUserId,
|
||||||
pub id: ConnectionId,
|
pub id: ConnectionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue