Dont show replies / mentions from blocked users. Fixes #4227

This commit is contained in:
Dessalines 2024-05-20 11:42:00 -04:00
parent a0ad7806cb
commit b7639a679b
2 changed files with 21 additions and 2 deletions

View file

@ -1,6 +1,6 @@
use crate::structs::CommentReplyView;
use diesel::{
dsl::exists,
dsl::{exists, not},
pg::Pg,
result::Error,
sql_types,
@ -217,6 +217,11 @@ fn queries<'a>() -> Queries<
CommentSortType::Top => query.order_by(comment_aggregates::score.desc()),
};
// Don't show replies from blocked persons
if let Some(my_person_id) = options.my_person_id {
query = query.filter(not(is_creator_blocked(my_person_id)));
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
query

View file

@ -1,6 +1,6 @@
use crate::structs::PersonMentionView;
use diesel::{
dsl::exists,
dsl::{exists, not},
pg::Pg,
result::Error,
sql_types,
@ -216,6 +216,11 @@ fn queries<'a>() -> Queries<
CommentSortType::Top => query.order_by(comment_aggregates::score.desc()),
};
// Don't show mentions from blocked persons
if let Some(my_person_id) = options.my_person_id {
query = query.filter(not(is_creator_blocked(my_person_id)));
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
query
@ -249,6 +254,15 @@ impl PersonMentionView {
person_mention::table
.inner_join(comment::table)
.left_join(
person_block::table.on(
comment::creator_id
.eq(person_block::target_id)
.and(person_block::person_id.eq(my_person_id)),
),
)
// Dont count replies from blocked users
.filter(person_block::person_id.is_null())
.filter(person_mention::recipient_id.eq(my_person_id))
.filter(person_mention::read.eq(false))
.filter(comment::deleted.eq(false))