mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-23 12:51:18 +00:00
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
This commit is contained in:
parent
df997dff49
commit
5c4dfb08c7
2 changed files with 16 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -76,10 +76,11 @@ pub async fn send_comment_ws_message<OP: ToString + Send + OperationType + 'stat
|
|||
view.comment = view.comment.blank_out_deleted_or_removed_info();
|
||||
}
|
||||
|
||||
let res = CommentResponse {
|
||||
let mut res = CommentResponse {
|
||||
comment_view: view,
|
||||
recipient_ids,
|
||||
form_id,
|
||||
// The sent out form id should be null
|
||||
form_id: None,
|
||||
};
|
||||
|
||||
context.chat_server().do_send(SendComment {
|
||||
|
@ -88,6 +89,10 @@ pub async fn send_comment_ws_message<OP: ToString + Send + OperationType + 'stat
|
|||
websocket_id,
|
||||
});
|
||||
|
||||
// The recipient_ids should be empty for returns
|
||||
res.recipient_ids = Vec::new();
|
||||
res.form_id = form_id;
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue