X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fapi%2Fpost.rs;fp=server%2Fsrc%2Fapi%2Fpost.rs;h=d38c10c9de7aeb4d45af550884e41472cbcdf006;hb=5c6258390c46159c16f49295314c6519215fc6ae;hp=a1801d0f2adb2ba2d9749349fa7b4466ddf690b2;hpb=b69524b498983da636b3a31f5acb74fbb1f13ab4;p=lemmy.git diff --git a/server/src/api/post.rs b/src/api/post.rs similarity index 97% rename from server/src/api/post.rs rename to src/api/post.rs index a1801d0f..d38c10c9 100644 --- a/server/src/api/post.rs +++ b/src/api/post.rs @@ -3,7 +3,7 @@ use crate::{ apub::{ApubLikeableType, ApubObjectType}, fetch_iframely_and_pictrs_data, websocket::{ - messages::{GetPostUsersOnline, JoinCommunityRoom, JoinPostRoom, SendPost}, + messages::{GetPostUsersOnline, JoinPostRoom, SendPost}, UserOperation, }, LemmyContext, @@ -159,7 +159,7 @@ impl Perform for GetPost { async fn perform( &self, context: &Data, - websocket_id: Option, + _websocket_id: Option, ) -> Result { let data: &GetPost = &self; let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?; @@ -197,13 +197,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 }) @@ -228,7 +221,7 @@ impl Perform for GetPosts { async fn perform( &self, context: &Data, - websocket_id: Option, + _websocket_id: Option, ) -> Result { let data: &GetPosts = &self; let user = get_user_from_jwt_opt(&data.auth, context.pool()).await?; @@ -268,18 +261,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 }) } } @@ -739,3 +720,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, + websocket_id: Option, + ) -> Result { + 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 }) + } +}