mirror of https://github.com/LemmyNet/lemmy.git
parent
2ab5172d35
commit
29a01ddaf1
|
@ -16,7 +16,7 @@ services:
|
|||
- postgres
|
||||
- iframely
|
||||
lemmy-isomorphic-ui:
|
||||
image: dessalines/lemmy-isomorphic-ui:v0.0.5
|
||||
image: dessalines/lemmy-isomorphic-ui:v0.0.6
|
||||
# image: lemmy-isomorphic-ui:latest
|
||||
ports:
|
||||
- "1235:1234"
|
||||
|
|
|
@ -26,7 +26,7 @@ services:
|
|||
- iframely
|
||||
|
||||
lemmy-isomorphic-ui:
|
||||
image: dessalines/lemmy-isomorphic-ui:v0.0.5
|
||||
image: dessalines/lemmy-isomorphic-ui:v0.0.6
|
||||
# image: lemmy-isomorphic-ui:latest
|
||||
ports:
|
||||
- "1235:1234"
|
||||
|
|
|
@ -129,3 +129,13 @@ pub struct TransferCommunity {
|
|||
pub user_id: i32,
|
||||
pub auth: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct CommunityJoin {
|
||||
pub community_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct CommunityJoinResponse {
|
||||
pub joined: bool,
|
||||
}
|
||||
|
|
|
@ -103,3 +103,13 @@ pub struct SavePost {
|
|||
pub save: bool,
|
||||
pub auth: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct PostJoin {
|
||||
pub post_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct PostJoinResponse {
|
||||
pub joined: bool,
|
||||
}
|
||||
|
|
|
@ -235,5 +235,5 @@ pub struct UserJoin {
|
|||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct UserJoinResponse {
|
||||
pub user_id: i32,
|
||||
pub joined: bool,
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
apub::{ApubLikeableType, ApubObjectType},
|
||||
blocking,
|
||||
websocket::{
|
||||
messages::{JoinCommunityRoom, SendComment},
|
||||
messages::SendComment,
|
||||
UserOperation,
|
||||
},
|
||||
DbPool,
|
||||
|
@ -664,7 +664,7 @@ impl Perform for GetComments {
|
|||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
websocket_id: Option<ConnectionId>,
|
||||
_websocket_id: Option<ConnectionId>,
|
||||
) -> Result<GetCommentsResponse, LemmyError> {
|
||||
let data: &GetComments = &self;
|
||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||
|
@ -694,18 +694,6 @@ impl Perform for GetComments {
|
|||
Err(_) => return Err(APIError::err("couldnt_get_comments").into()),
|
||||
};
|
||||
|
||||
if let Some(id) = websocket_id {
|
||||
// You don't need to join the specific community room, bc this is already handled by
|
||||
// GetCommunity
|
||||
if data.community_id.is_none() {
|
||||
// 0 is the "all" community
|
||||
context.chat_server().do_send(JoinCommunityRoom {
|
||||
community_id: 0,
|
||||
id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(GetCommentsResponse { comments })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Perform for GetCommunity {
|
|||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
websocket_id: Option<ConnectionId>,
|
||||
_websocket_id: Option<ConnectionId>,
|
||||
) -> Result<GetCommunityResponse, LemmyError> {
|
||||
let data: &GetCommunity = &self;
|
||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||
|
@ -95,12 +95,6 @@ impl Perform for GetCommunity {
|
|||
Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
|
||||
};
|
||||
|
||||
if let Some(id) = websocket_id {
|
||||
context
|
||||
.chat_server()
|
||||
.do_send(JoinCommunityRoom { community_id, id });
|
||||
}
|
||||
|
||||
let online = context
|
||||
.chat_server()
|
||||
.send(GetCommunityUsersOnline { community_id })
|
||||
|
@ -856,3 +850,25 @@ pub fn send_community_websocket(
|
|||
websocket_id,
|
||||
});
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for CommunityJoin {
|
||||
type Response = CommunityJoinResponse;
|
||||
|
||||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
websocket_id: Option<ConnectionId>,
|
||||
) -> Result<CommunityJoinResponse, LemmyError> {
|
||||
let data: &CommunityJoin = &self;
|
||||
|
||||
if let Some(ws_id) = websocket_id {
|
||||
context.chat_server().do_send(JoinCommunityRoom {
|
||||
community_id: data.community_id,
|
||||
id: ws_id,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(CommunityJoinResponse { joined: true })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
blocking,
|
||||
fetch_iframely_and_pictrs_data,
|
||||
websocket::{
|
||||
messages::{GetPostUsersOnline, JoinCommunityRoom, JoinPostRoom, SendPost},
|
||||
messages::{GetPostUsersOnline, JoinPostRoom, SendPost},
|
||||
UserOperation,
|
||||
},
|
||||
LemmyContext,
|
||||
|
@ -169,7 +169,7 @@ impl Perform for GetPost {
|
|||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
websocket_id: Option<ConnectionId>,
|
||||
_websocket_id: Option<ConnectionId>,
|
||||
) -> Result<GetPostResponse, LemmyError> {
|
||||
let data: &GetPost = &self;
|
||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||
|
@ -207,13 +207,6 @@ impl Perform for GetPost {
|
|||
})
|
||||
.await??;
|
||||
|
||||
if let Some(id) = websocket_id {
|
||||
context.chat_server().do_send(JoinPostRoom {
|
||||
post_id: data.id,
|
||||
id,
|
||||
});
|
||||
}
|
||||
|
||||
let online = context
|
||||
.chat_server()
|
||||
.send(GetPostUsersOnline { post_id: data.id })
|
||||
|
@ -238,7 +231,7 @@ impl Perform for GetPosts {
|
|||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
websocket_id: Option<ConnectionId>,
|
||||
_websocket_id: Option<ConnectionId>,
|
||||
) -> Result<GetPostsResponse, LemmyError> {
|
||||
let data: &GetPosts = &self;
|
||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||
|
@ -278,18 +271,6 @@ impl Perform for GetPosts {
|
|||
Err(_e) => return Err(APIError::err("couldnt_get_posts").into()),
|
||||
};
|
||||
|
||||
if let Some(id) = websocket_id {
|
||||
// You don't need to join the specific community room, bc this is already handled by
|
||||
// GetCommunity
|
||||
if data.community_id.is_none() {
|
||||
// 0 is the "all" community
|
||||
context.chat_server().do_send(JoinCommunityRoom {
|
||||
community_id: 0,
|
||||
id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(GetPostsResponse { posts })
|
||||
}
|
||||
}
|
||||
|
@ -749,3 +730,25 @@ impl Perform for SavePost {
|
|||
Ok(PostResponse { post: post_view })
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for PostJoin {
|
||||
type Response = PostJoinResponse;
|
||||
|
||||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
websocket_id: Option<ConnectionId>,
|
||||
) -> Result<PostJoinResponse, LemmyError> {
|
||||
let data: &PostJoin = &self;
|
||||
|
||||
if let Some(ws_id) = websocket_id {
|
||||
context.chat_server().do_send(JoinPostRoom {
|
||||
post_id: data.post_id,
|
||||
id: ws_id,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(PostJoinResponse { joined: true })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1279,6 +1279,6 @@ impl Perform for UserJoin {
|
|||
});
|
||||
}
|
||||
|
||||
Ok(UserJoinResponse { user_id: user.id })
|
||||
Ok(UserJoinResponse { joined: true })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
|||
.route("/remove", web::post().to(route_post::<RemoveCommunity>))
|
||||
.route("/transfer", web::post().to(route_post::<TransferCommunity>))
|
||||
.route("/ban_user", web::post().to(route_post::<BanFromCommunity>))
|
||||
.route("/mod", web::post().to(route_post::<AddModToCommunity>)),
|
||||
.route("/mod", web::post().to(route_post::<AddModToCommunity>))
|
||||
.route("/join", web::post().to(route_post::<CommunityJoin>)),
|
||||
)
|
||||
// Post
|
||||
.service(
|
||||
|
@ -76,7 +77,8 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
|||
.route("/sticky", web::post().to(route_post::<StickyPost>))
|
||||
.route("/list", web::get().to(route_get::<GetPosts>))
|
||||
.route("/like", web::post().to(route_post::<CreatePostLike>))
|
||||
.route("/save", web::put().to(route_post::<SavePost>)),
|
||||
.route("/save", web::put().to(route_post::<SavePost>))
|
||||
.route("/join", web::post().to(route_post::<PostJoin>)),
|
||||
)
|
||||
// Comment
|
||||
.service(
|
||||
|
|
|
@ -398,6 +398,8 @@ impl ChatServer {
|
|||
UserOperation::PasswordReset => do_user_operation::<PasswordReset>(args).await,
|
||||
UserOperation::PasswordChange => do_user_operation::<PasswordChange>(args).await,
|
||||
UserOperation::UserJoin => do_user_operation::<UserJoin>(args).await,
|
||||
UserOperation::PostJoin => do_user_operation::<PostJoin>(args).await,
|
||||
UserOperation::CommunityJoin => do_user_operation::<CommunityJoin>(args).await,
|
||||
UserOperation::SaveUserSettings => do_user_operation::<SaveUserSettings>(args).await,
|
||||
|
||||
// Private Message ops
|
||||
|
|
|
@ -62,4 +62,6 @@ pub enum UserOperation {
|
|||
GetComments,
|
||||
GetSiteConfig,
|
||||
SaveSiteConfig,
|
||||
PostJoin,
|
||||
CommunityJoin,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue