diff --git a/lemmy_api/src/comment.rs b/lemmy_api/src/comment.rs index fca5eb5de..fbbed6d62 100644 --- a/lemmy_api/src/comment.rs +++ b/lemmy_api/src/comment.rs @@ -152,7 +152,7 @@ impl Perform for CreateComment { comment_view.comment.read = true; } - let mut res = CommentResponse { + let res = CommentResponse { comment_view, recipient_ids, form_id: data.form_id.to_owned(), @@ -164,11 +164,6 @@ impl Perform for CreateComment { websocket_id, }); - // strip out the recipient_ids, so that - // users don't get double notifs - // TODO Do this in a different way - res.recipient_ids = Vec::new(); - Ok(res) } } @@ -233,7 +228,7 @@ impl Perform for EditComment { }) .await??; - let mut res = CommentResponse { + let res = CommentResponse { comment_view, recipient_ids, form_id: data.form_id.to_owned(), @@ -245,11 +240,6 @@ impl Perform for EditComment { websocket_id, }); - // strip out the recipient_ids, so that - // users don't get double notifs - // TODO again - res.recipient_ids = Vec::new(); - Ok(res) } } @@ -318,7 +308,7 @@ impl Perform for DeleteComment { ) .await?; - let mut res = CommentResponse { + let res = CommentResponse { comment_view, recipient_ids, form_id: None, // TODO a comment delete might clear forms? @@ -330,11 +320,6 @@ impl Perform for DeleteComment { websocket_id, }); - // strip out the recipient_ids, so that - // users don't get double notifs - // TODO again - res.recipient_ids = Vec::new(); - Ok(res) } } @@ -414,7 +399,7 @@ impl Perform for RemoveComment { ) .await?; - let mut res = CommentResponse { + let res = CommentResponse { comment_view, recipient_ids, form_id: None, // TODO maybe this might clear other forms @@ -426,11 +411,6 @@ impl Perform for RemoveComment { websocket_id, }); - // strip out the recipient_ids, so that - // users don't get double notifs - // TODO again - res.recipient_ids = Vec::new(); - Ok(res) } } @@ -602,7 +582,7 @@ impl Perform for CreateCommentLike { }) .await??; - let mut res = CommentResponse { + let res = CommentResponse { comment_view: liked_comment, recipient_ids, form_id: None, @@ -614,11 +594,6 @@ impl Perform for CreateCommentLike { websocket_id, }); - // strip out the recipient_ids, so that - // users don't get double notifs - res.recipient_ids = Vec::new(); - // TODO why - Ok(res) } } diff --git a/lemmy_api/src/community.rs b/lemmy_api/src/community.rs index f01e07404..7cb7be7d8 100644 --- a/lemmy_api/src/community.rs +++ b/lemmy_api/src/community.rs @@ -853,15 +853,13 @@ fn send_community_websocket( websocket_id: Option, op: UserOperation, ) { - // TODO is there any way around this? // Strip out the user id and subscribed when sending to others - // let mut res_sent = res.clone(); - // res_sent.community_view.user_id = None; - // res_sent.community.subscribed = None; + let mut res_sent = res.clone(); + res_sent.community_view.subscribed = false; context.chat_server().do_send(SendCommunityRoomMessage { op, - response: res.to_owned(), + response: res_sent, community_id: res.community_view.community.id, websocket_id, }); diff --git a/lemmy_websocket/src/chat_server.rs b/lemmy_websocket/src/chat_server.rs index f149d6e1e..cdfac6c51 100644 --- a/lemmy_websocket/src/chat_server.rs +++ b/lemmy_websocket/src/chat_server.rs @@ -328,15 +328,14 @@ impl ChatServer { comment: &CommentResponse, websocket_id: Option, ) -> Result<(), LemmyError> { - let comment_reply_sent = comment.clone(); - // TODO what is this here - // comment_reply_sent.comment_view.my_vote = None; - // comment_reply_sent.comment.user_id = None; + let mut comment_reply_sent = comment.clone(); - let mut comment_post_sent = comment_reply_sent.clone(); - comment_post_sent.recipient_ids = Vec::new(); + // Strip out my specific user info + comment_reply_sent.comment_view.my_vote = None; // Send it to the post room + let mut comment_post_sent = comment_reply_sent.clone(); + comment_post_sent.recipient_ids = Vec::new(); self.send_post_room_message( user_operation, &comment_post_sent, @@ -344,16 +343,6 @@ impl ChatServer { websocket_id, )?; - // Send it to the recipient(s) including the mentioned users - for recipient_id in &comment_reply_sent.recipient_ids { - self.send_user_room_message( - user_operation, - &comment_reply_sent, - *recipient_id, - websocket_id, - )?; - } - // Send it to the community too self.send_community_room_message(user_operation, &comment_post_sent, 0, websocket_id)?; self.send_community_room_message( @@ -363,6 +352,18 @@ impl ChatServer { websocket_id, )?; + // Remove the form id here to separate mentions / user messages from post or community comments + comment_reply_sent.form_id = None; + // Send it to the recipient(s) including the mentioned users + for recipient_id in &comment_reply_sent.recipient_ids { + self.send_user_room_message( + user_operation, + &comment_reply_sent, + *recipient_id, + websocket_id, + )?; + } + Ok(()) } @@ -375,19 +376,17 @@ impl ChatServer { let community_id = post_res.post_view.community.id; // Don't send my data with it - // TODO no idea what to do here - // let mut post_sent = post_res.clone(); - // post_sent.post.my_vote = None; - // post_sent.post.user_id = None; + let mut post_sent = post_res.clone(); + post_sent.post_view.my_vote = None; // Send it to /c/all and that community - self.send_community_room_message(user_operation, &post_res, 0, websocket_id)?; - self.send_community_room_message(user_operation, &post_res, community_id, websocket_id)?; + self.send_community_room_message(user_operation, &post_sent, 0, websocket_id)?; + self.send_community_room_message(user_operation, &post_sent, community_id, websocket_id)?; // Send it to the post room self.send_post_room_message( user_operation, - &post_res, + &post_sent, post_res.post_view.post.id, websocket_id, )?;