From: Dessalines Date: Sat, 4 Sep 2021 12:47:41 +0000 (-0400) Subject: Fixing some comment websocket issues. (#1768) X-Git-Url: http://these/git/%7B%60/feeds/u/readmes/static/bundle.js?a=commitdiff_plain;h=0940fb5f00b85f7c5388b8aeac322f8944c9d676;p=lemmy.git Fixing some comment websocket issues. (#1768) - Wasn't correctly getting comment parent user for mark as read. Fixes #1767 - Was using all recipients for simple comment return. Fixes #1766 --- diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index c25966c7..94c30692 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -21,6 +21,7 @@ use lemmy_apub::{ }; use lemmy_db_queries::{source::comment::Comment_, Crud, Likeable}; use lemmy_db_schema::source::comment::*; +use lemmy_db_views::comment_view::CommentView; use lemmy_utils::{ utils::{remove_slurs, scrape_text_for_mentions}, ApiError, @@ -143,8 +144,15 @@ impl PerformCrud for CreateComment { ) .await?; + let person_id = local_user_view.person.id; + let comment_id = inserted_comment.id; + let comment_view = blocking(context.pool(), move |conn| { + CommentView::read(conn, comment_id, Some(person_id)) + }) + .await??; + // If its a comment to yourself, mark it as read - if local_user_view.person.id == inserted_comment.creator_id { + if local_user_view.person.id == comment_view.get_recipient_id() { let comment_id = inserted_comment.id; blocking(context.pool(), move |conn| { Comment::update_read(conn, comment_id, true) diff --git a/crates/websocket/src/send.rs b/crates/websocket/src/send.rs index 130d94a4..a49759d6 100644 --- a/crates/websocket/src/send.rs +++ b/crates/websocket/src/send.rs @@ -76,10 +76,11 @@ pub async fn send_comment_ws_message