- 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 == comment_view.get_recipient_id() {
- let comment_id = inserted_comment.id;
- blocking(context.pool(), move |conn| {
- Comment::update_read(conn, comment_id, true)
- })
- .await?
- .map_err(|_| ApiError::err("couldnt_update_comment"))?;
+ // If the parent has PersonMentions mark them as read too
+ let person_id = local_user_view.person.id;
+ let person_mention =
+ PersonMention::read_by_comment_and_person(&mut context.pool(), parent_id, person_id).await;
+ if let Ok(mention) = person_mention {
+ PersonMention::update(
+ &mut context.pool(),
+ mention.id,
+ &PersonMentionUpdateForm { read: Some(true) },
+ )
+ .await
+ .with_lemmy_type(LemmyErrorType::CouldntUpdatePersonMentions)?;
+ }