Fix unnecessarily duplicated notifs (#4578)
* add check to remove duplicated notifs * added comments
This commit is contained in:
parent
067332553d
commit
60f9a97dfa
1 changed files with 48 additions and 43 deletions
|
@ -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,6 +163,8 @@ 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 {
|
||||
// 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 {
|
||||
|
@ -190,6 +192,7 @@ pub async fn send_local_notifs(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let check_blocks = check_person_instance_community_block(
|
||||
person.id,
|
||||
|
@ -205,6 +208,7 @@ 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 {
|
||||
if !recipient_ids.contains(&parent_user_view.local_user.id) {
|
||||
recipient_ids.push(parent_user_view.local_user.id);
|
||||
|
||||
let comment_reply_form = CommentReplyInsertForm {
|
||||
|
@ -233,6 +237,7 @@ pub async fn send_local_notifs(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(recipient_ids)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue