mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 04:11:17 +00:00
Fixing API tests.
This commit is contained in:
parent
fc45266bc3
commit
0b3b711d82
6 changed files with 18 additions and 20 deletions
|
@ -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<MentionData>,
|
||||
comment_id: CommentId,
|
||||
my_local_user: &LocalUserView,
|
||||
person: &Person,
|
||||
do_send_email: bool,
|
||||
context: &LemmyContext,
|
||||
) -> LemmyResult<Vec<LocalUserId>> {
|
||||
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;
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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()),
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue