diff --git a/crates/api_common/src/build_response.rs b/crates/api_common/src/build_response.rs index 1b90832d1..200284b00 100644 --- a/crates/api_common/src/build_response.rs +++ b/crates/api_common/src/build_response.rs @@ -17,6 +17,7 @@ use lemmy_db_schema::{ actor_language::CommunityLanguage, comment::Comment, comment_reply::{CommentReply, CommentReplyInsertForm}, + person::Person, person_mention::{PersonMention, PersonMentionInsertForm}, }, traits::Crud, @@ -96,24 +97,18 @@ pub async fn build_post_response( pub async fn send_local_notifs( mentions: Vec, comment_id: CommentId, - my_local_user: &LocalUserView, + person: &Person, do_send_email: bool, context: &LemmyContext, ) -> LemmyResult> { let mut recipient_ids = Vec::new(); let inbox_link = format!("{}/inbox", context.settings().get_protocol_and_hostname()); - let person = &my_local_user.person; - // let person = my_local_user.person; // Read the comment view to get extra info - let comment_view = CommentView::read( - &mut context.pool(), - comment_id, - Some(&my_local_user.local_user), - ) - .await? - .ok_or(LemmyErrorType::CouldntFindComment)?; + let comment_view = CommentView::read(&mut context.pool(), comment_id, None) + .await? + .ok_or(LemmyErrorType::CouldntFindComment)?; let comment = comment_view.comment; let post = comment_view.post; let community = comment_view.community; diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 2f5aad921..b7c65740c 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -131,7 +131,7 @@ pub async fn create_comment( let recipient_ids = send_local_notifs( mentions, inserted_comment_id, - &local_user_view, + &local_user_view.person, true, &context, ) diff --git a/crates/api_crud/src/comment/delete.rs b/crates/api_crud/src/comment/delete.rs index 3489bcaf2..29706d365 100644 --- a/crates/api_crud/src/comment/delete.rs +++ b/crates/api_crud/src/comment/delete.rs @@ -60,7 +60,7 @@ pub async fn delete_comment( .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; let recipient_ids = - send_local_notifs(vec![], comment_id, &local_user_view, false, &context).await?; + send_local_notifs(vec![], comment_id, &local_user_view.person, false, &context).await?; let updated_comment_id = updated_comment.id; ActivityChannel::submit_activity( diff --git a/crates/api_crud/src/comment/remove.rs b/crates/api_crud/src/comment/remove.rs index 2c61c8efe..83ef82e3a 100644 --- a/crates/api_crud/src/comment/remove.rs +++ b/crates/api_crud/src/comment/remove.rs @@ -73,7 +73,7 @@ pub async fn remove_comment( ModRemoveComment::create(&mut context.pool(), &form).await?; let recipient_ids = - send_local_notifs(vec![], comment_id, &local_user_view, false, &context).await?; + send_local_notifs(vec![], comment_id, &local_user_view.person, false, &context).await?; let updated_comment_id = updated_comment.id; ActivityChannel::submit_activity( diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 59804465b..32bd08240 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -85,8 +85,14 @@ pub async fn update_comment( // Do the mentions / recipients let updated_comment_content = updated_comment.content.clone(); let mentions = scrape_text_for_mentions(&updated_comment_content); - let recipient_ids = - send_local_notifs(mentions, comment_id, &local_user_view, false, &context).await?; + let recipient_ids = send_local_notifs( + mentions, + comment_id, + &local_user_view.person, + false, + &context, + ) + .await?; ActivityChannel::submit_activity( SendActivityData::UpdateComment(updated_comment.clone()), diff --git a/crates/apub/src/activities/create_or_update/comment.rs b/crates/apub/src/activities/create_or_update/comment.rs index c4ec00244..2406d2eb3 100644 --- a/crates/apub/src/activities/create_or_update/comment.rs +++ b/crates/apub/src/activities/create_or_update/comment.rs @@ -39,7 +39,6 @@ use lemmy_db_schema::{ }, traits::{Crud, Likeable}, }; -use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{ error::{LemmyError, LemmyResult}, utils::mention::scrape_text_for_mentions, @@ -179,10 +178,8 @@ impl ActivityHandler for CreateOrUpdateNote { // anyway. // TODO: for compatibility with other projects, it would be much better to read this from cc or // tags - if let Some(local_user) = LocalUserView::read_person(&mut context.pool(), actor.id).await? { - let mentions = scrape_text_for_mentions(&comment.content); - send_local_notifs(mentions, comment.id, &local_user, do_send_email, context).await?; - } + let mentions = scrape_text_for_mentions(&comment.content); + send_local_notifs(mentions, comment.id, &actor, do_send_email, context).await?; Ok(()) } }