mirror of https://github.com/LemmyNet/lemmy.git
parent
2ab5172d35
commit
29a01ddaf1
|
@ -16,7 +16,7 @@ services:
|
||||||
- postgres
|
- postgres
|
||||||
- iframely
|
- iframely
|
||||||
lemmy-isomorphic-ui:
|
lemmy-isomorphic-ui:
|
||||||
image: dessalines/lemmy-isomorphic-ui:v0.0.5
|
image: dessalines/lemmy-isomorphic-ui:v0.0.6
|
||||||
# image: lemmy-isomorphic-ui:latest
|
# image: lemmy-isomorphic-ui:latest
|
||||||
ports:
|
ports:
|
||||||
- "1235:1234"
|
- "1235:1234"
|
||||||
|
|
|
@ -26,7 +26,7 @@ services:
|
||||||
- iframely
|
- iframely
|
||||||
|
|
||||||
lemmy-isomorphic-ui:
|
lemmy-isomorphic-ui:
|
||||||
image: dessalines/lemmy-isomorphic-ui:v0.0.5
|
image: dessalines/lemmy-isomorphic-ui:v0.0.6
|
||||||
# image: lemmy-isomorphic-ui:latest
|
# image: lemmy-isomorphic-ui:latest
|
||||||
ports:
|
ports:
|
||||||
- "1235:1234"
|
- "1235:1234"
|
||||||
|
|
|
@ -129,3 +129,13 @@ pub struct TransferCommunity {
|
||||||
pub user_id: i32,
|
pub user_id: i32,
|
||||||
pub auth: String,
|
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 save: bool,
|
||||||
pub auth: String,
|
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)]
|
#[derive(Serialize, Clone)]
|
||||||
pub struct UserJoinResponse {
|
pub struct UserJoinResponse {
|
||||||
pub user_id: i32,
|
pub joined: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
apub::{ApubLikeableType, ApubObjectType},
|
apub::{ApubLikeableType, ApubObjectType},
|
||||||
blocking,
|
blocking,
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{JoinCommunityRoom, SendComment},
|
messages::SendComment,
|
||||||
UserOperation,
|
UserOperation,
|
||||||
},
|
},
|
||||||
DbPool,
|
DbPool,
|
||||||
|
@ -664,7 +664,7 @@ impl Perform for GetComments {
|
||||||
async fn perform(
|
async fn perform(
|
||||||
&self,
|
&self,
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
websocket_id: Option<ConnectionId>,
|
_websocket_id: Option<ConnectionId>,
|
||||||
) -> Result<GetCommentsResponse, LemmyError> {
|
) -> Result<GetCommentsResponse, LemmyError> {
|
||||||
let data: &GetComments = &self;
|
let data: &GetComments = &self;
|
||||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
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()),
|
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 })
|
Ok(GetCommentsResponse { comments })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl Perform for GetCommunity {
|
||||||
async fn perform(
|
async fn perform(
|
||||||
&self,
|
&self,
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
websocket_id: Option<ConnectionId>,
|
_websocket_id: Option<ConnectionId>,
|
||||||
) -> Result<GetCommunityResponse, LemmyError> {
|
) -> Result<GetCommunityResponse, LemmyError> {
|
||||||
let data: &GetCommunity = &self;
|
let data: &GetCommunity = &self;
|
||||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
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()),
|
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
|
let online = context
|
||||||
.chat_server()
|
.chat_server()
|
||||||
.send(GetCommunityUsersOnline { community_id })
|
.send(GetCommunityUsersOnline { community_id })
|
||||||
|
@ -856,3 +850,25 @@ pub fn send_community_websocket(
|
||||||
websocket_id,
|
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,
|
blocking,
|
||||||
fetch_iframely_and_pictrs_data,
|
fetch_iframely_and_pictrs_data,
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{GetPostUsersOnline, JoinCommunityRoom, JoinPostRoom, SendPost},
|
messages::{GetPostUsersOnline, JoinPostRoom, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
},
|
},
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
|
@ -169,7 +169,7 @@ impl Perform for GetPost {
|
||||||
async fn perform(
|
async fn perform(
|
||||||
&self,
|
&self,
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
websocket_id: Option<ConnectionId>,
|
_websocket_id: Option<ConnectionId>,
|
||||||
) -> Result<GetPostResponse, LemmyError> {
|
) -> Result<GetPostResponse, LemmyError> {
|
||||||
let data: &GetPost = &self;
|
let data: &GetPost = &self;
|
||||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||||
|
@ -207,13 +207,6 @@ impl Perform for GetPost {
|
||||||
})
|
})
|
||||||
.await??;
|
.await??;
|
||||||
|
|
||||||
if let Some(id) = websocket_id {
|
|
||||||
context.chat_server().do_send(JoinPostRoom {
|
|
||||||
post_id: data.id,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let online = context
|
let online = context
|
||||||
.chat_server()
|
.chat_server()
|
||||||
.send(GetPostUsersOnline { post_id: data.id })
|
.send(GetPostUsersOnline { post_id: data.id })
|
||||||
|
@ -238,7 +231,7 @@ impl Perform for GetPosts {
|
||||||
async fn perform(
|
async fn perform(
|
||||||
&self,
|
&self,
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
websocket_id: Option<ConnectionId>,
|
_websocket_id: Option<ConnectionId>,
|
||||||
) -> Result<GetPostsResponse, LemmyError> {
|
) -> Result<GetPostsResponse, LemmyError> {
|
||||||
let data: &GetPosts = &self;
|
let data: &GetPosts = &self;
|
||||||
let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?;
|
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()),
|
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 })
|
Ok(GetPostsResponse { posts })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,3 +730,25 @@ impl Perform for SavePost {
|
||||||
Ok(PostResponse { post: post_view })
|
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("/remove", web::post().to(route_post::<RemoveCommunity>))
|
||||||
.route("/transfer", web::post().to(route_post::<TransferCommunity>))
|
.route("/transfer", web::post().to(route_post::<TransferCommunity>))
|
||||||
.route("/ban_user", web::post().to(route_post::<BanFromCommunity>))
|
.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
|
// Post
|
||||||
.service(
|
.service(
|
||||||
|
@ -76,7 +77,8 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
.route("/sticky", web::post().to(route_post::<StickyPost>))
|
.route("/sticky", web::post().to(route_post::<StickyPost>))
|
||||||
.route("/list", web::get().to(route_get::<GetPosts>))
|
.route("/list", web::get().to(route_get::<GetPosts>))
|
||||||
.route("/like", web::post().to(route_post::<CreatePostLike>))
|
.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
|
// Comment
|
||||||
.service(
|
.service(
|
||||||
|
|
|
@ -398,6 +398,8 @@ impl ChatServer {
|
||||||
UserOperation::PasswordReset => do_user_operation::<PasswordReset>(args).await,
|
UserOperation::PasswordReset => do_user_operation::<PasswordReset>(args).await,
|
||||||
UserOperation::PasswordChange => do_user_operation::<PasswordChange>(args).await,
|
UserOperation::PasswordChange => do_user_operation::<PasswordChange>(args).await,
|
||||||
UserOperation::UserJoin => do_user_operation::<UserJoin>(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,
|
UserOperation::SaveUserSettings => do_user_operation::<SaveUserSettings>(args).await,
|
||||||
|
|
||||||
// Private Message ops
|
// Private Message ops
|
||||||
|
|
|
@ -62,4 +62,6 @@ pub enum UserOperation {
|
||||||
GetComments,
|
GetComments,
|
||||||
GetSiteConfig,
|
GetSiteConfig,
|
||||||
SaveSiteConfig,
|
SaveSiteConfig,
|
||||||
|
PostJoin,
|
||||||
|
CommunityJoin,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue