|
|
|
@ -112,7 +112,7 @@ pub async fn send_local_notifs(
|
|
|
|
|
if let Ok(mention_user_view) = user_view {
|
|
|
|
|
// TODO
|
|
|
|
|
// At some point, make it so you can't tag the parent creator either
|
|
|
|
|
// This can cause two notifications, one for reply and the other for mention
|
|
|
|
|
// Potential duplication of notifications, one for reply and the other for mention, is handled below by checking recipient ids
|
|
|
|
|
recipient_ids.push(mention_user_view.local_user.id);
|
|
|
|
|
|
|
|
|
|
let user_mention_form = PersonMentionInsertForm {
|
|
|
|
@ -163,30 +163,33 @@ pub async fn send_local_notifs(
|
|
|
|
|
if parent_comment.creator_id != person.id && !check_blocks {
|
|
|
|
|
let user_view = LocalUserView::read_person(&mut context.pool(), parent_creator_id).await;
|
|
|
|
|
if let Ok(parent_user_view) = user_view {
|
|
|
|
|
recipient_ids.push(parent_user_view.local_user.id);
|
|
|
|
|
|
|
|
|
|
let comment_reply_form = CommentReplyInsertForm {
|
|
|
|
|
recipient_id: parent_user_view.person.id,
|
|
|
|
|
comment_id: comment.id,
|
|
|
|
|
read: None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Allow this to fail softly, since comment edits might re-update or replace it
|
|
|
|
|
// Let the uniqueness handle this fail
|
|
|
|
|
CommentReply::create(&mut context.pool(), &comment_reply_form)
|
|
|
|
|
.await
|
|
|
|
|
.ok();
|
|
|
|
|
|
|
|
|
|
if do_send_email {
|
|
|
|
|
let lang = get_interface_language(&parent_user_view);
|
|
|
|
|
let content = markdown_to_html(&comment.content);
|
|
|
|
|
send_email_to_user(
|
|
|
|
|
&parent_user_view,
|
|
|
|
|
&lang.notification_comment_reply_subject(&person.name),
|
|
|
|
|
&lang.notification_comment_reply_body(&content, &inbox_link, &person.name),
|
|
|
|
|
context.settings(),
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
// Don't duplicate notif if already mentioned by checking recipient ids
|
|
|
|
|
if !recipient_ids.contains(&parent_user_view.local_user.id) {
|
|
|
|
|
recipient_ids.push(parent_user_view.local_user.id);
|
|
|
|
|
|
|
|
|
|
let comment_reply_form = CommentReplyInsertForm {
|
|
|
|
|
recipient_id: parent_user_view.person.id,
|
|
|
|
|
comment_id: comment.id,
|
|
|
|
|
read: None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Allow this to fail softly, since comment edits might re-update or replace it
|
|
|
|
|
// Let the uniqueness handle this fail
|
|
|
|
|
CommentReply::create(&mut context.pool(), &comment_reply_form)
|
|
|
|
|
.await
|
|
|
|
|
.ok();
|
|
|
|
|
|
|
|
|
|
if do_send_email {
|
|
|
|
|
let lang = get_interface_language(&parent_user_view);
|
|
|
|
|
let content = markdown_to_html(&comment.content);
|
|
|
|
|
send_email_to_user(
|
|
|
|
|
&parent_user_view,
|
|
|
|
|
&lang.notification_comment_reply_subject(&person.name),
|
|
|
|
|
&lang.notification_comment_reply_body(&content, &inbox_link, &person.name),
|
|
|
|
|
context.settings(),
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -205,30 +208,32 @@ pub async fn send_local_notifs(
|
|
|
|
|
let creator_id = post.creator_id;
|
|
|
|
|
let parent_user = LocalUserView::read_person(&mut context.pool(), creator_id).await;
|
|
|
|
|
if let Ok(parent_user_view) = parent_user {
|
|
|
|
|
recipient_ids.push(parent_user_view.local_user.id);
|
|
|
|
|
|
|
|
|
|
let comment_reply_form = CommentReplyInsertForm {
|
|
|
|
|
recipient_id: parent_user_view.person.id,
|
|
|
|
|
comment_id: comment.id,
|
|
|
|
|
read: None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Allow this to fail softly, since comment edits might re-update or replace it
|
|
|
|
|
// Let the uniqueness handle this fail
|
|
|
|
|
CommentReply::create(&mut context.pool(), &comment_reply_form)
|
|
|
|
|
.await
|
|
|
|
|
.ok();
|
|
|
|
|
|
|
|
|
|
if do_send_email {
|
|
|
|
|
let lang = get_interface_language(&parent_user_view);
|
|
|
|
|
let content = markdown_to_html(&comment.content);
|
|
|
|
|
send_email_to_user(
|
|
|
|
|
&parent_user_view,
|
|
|
|
|
&lang.notification_post_reply_subject(&person.name),
|
|
|
|
|
&lang.notification_post_reply_body(&content, &inbox_link, &person.name),
|
|
|
|
|
context.settings(),
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
if !recipient_ids.contains(&parent_user_view.local_user.id) {
|
|
|
|
|
recipient_ids.push(parent_user_view.local_user.id);
|
|
|
|
|
|
|
|
|
|
let comment_reply_form = CommentReplyInsertForm {
|
|
|
|
|
recipient_id: parent_user_view.person.id,
|
|
|
|
|
comment_id: comment.id,
|
|
|
|
|
read: None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Allow this to fail softly, since comment edits might re-update or replace it
|
|
|
|
|
// Let the uniqueness handle this fail
|
|
|
|
|
CommentReply::create(&mut context.pool(), &comment_reply_form)
|
|
|
|
|
.await
|
|
|
|
|
.ok();
|
|
|
|
|
|
|
|
|
|
if do_send_email {
|
|
|
|
|
let lang = get_interface_language(&parent_user_view);
|
|
|
|
|
let content = markdown_to_html(&comment.content);
|
|
|
|
|
send_email_to_user(
|
|
|
|
|
&parent_user_view,
|
|
|
|
|
&lang.notification_post_reply_subject(&person.name),
|
|
|
|
|
&lang.notification_post_reply_body(&content, &inbox_link, &person.name),
|
|
|
|
|
context.settings(),
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|