mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 22:01:49 +00:00
Allow filtering out of deleted and removed comments when getting person details (#2446)
undefined
This commit is contained in:
parent
004efd5d94
commit
4e6409f325
3 changed files with 9 additions and 0 deletions
|
@ -99,6 +99,7 @@ pub struct GetPersonDetails {
|
||||||
pub limit: Option<i64>,
|
pub limit: Option<i64>,
|
||||||
pub community_id: Option<CommunityId>,
|
pub community_id: Option<CommunityId>,
|
||||||
pub saved_only: Option<bool>,
|
pub saved_only: Option<bool>,
|
||||||
|
pub show_deleted_and_removed: Option<bool>,
|
||||||
pub auth: Option<Sensitive<String>>,
|
pub auth: Option<Sensitive<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ impl PerformCrud for GetPersonDetails {
|
||||||
let page = data.page;
|
let page = data.page;
|
||||||
let limit = data.limit;
|
let limit = data.limit;
|
||||||
let saved_only = data.saved_only;
|
let saved_only = data.saved_only;
|
||||||
|
let show_deleted_and_removed = data.show_deleted_and_removed;
|
||||||
let community_id = data.community_id;
|
let community_id = data.community_id;
|
||||||
|
|
||||||
let (posts, comments) = blocking(context.pool(), move |conn| {
|
let (posts, comments) = blocking(context.pool(), move |conn| {
|
||||||
|
@ -77,6 +78,7 @@ impl PerformCrud for GetPersonDetails {
|
||||||
.local_user(local_user.as_ref())
|
.local_user(local_user.as_ref())
|
||||||
.sort(sort.map(post_to_comment_sort_type))
|
.sort(sort.map(post_to_comment_sort_type))
|
||||||
.saved_only(saved_only)
|
.saved_only(saved_only)
|
||||||
|
.show_deleted_and_removed(show_deleted_and_removed)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.page(page)
|
.page(page)
|
||||||
.limit(limit);
|
.limit(limit);
|
||||||
|
|
|
@ -165,6 +165,7 @@ pub struct CommentQuery<'a> {
|
||||||
local_user: Option<&'a LocalUser>,
|
local_user: Option<&'a LocalUser>,
|
||||||
search_term: Option<String>,
|
search_term: Option<String>,
|
||||||
saved_only: Option<bool>,
|
saved_only: Option<bool>,
|
||||||
|
show_deleted_and_removed: Option<bool>,
|
||||||
page: Option<i64>,
|
page: Option<i64>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
max_depth: Option<i32>,
|
max_depth: Option<i32>,
|
||||||
|
@ -302,6 +303,11 @@ impl<'a> CommentQuery<'a> {
|
||||||
query = query.filter(comment_saved::id.is_not_null());
|
query = query.filter(comment_saved::id.is_not_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.show_deleted_and_removed.unwrap_or(true) {
|
||||||
|
query = query.filter(comment::deleted.eq(false));
|
||||||
|
query = query.filter(comment::removed.eq(false));
|
||||||
|
}
|
||||||
|
|
||||||
if !self.local_user.map(|l| l.show_bot_accounts).unwrap_or(true) {
|
if !self.local_user.map(|l| l.show_bot_accounts).unwrap_or(true) {
|
||||||
query = query.filter(person::bot_account.eq(false));
|
query = query.filter(person::bot_account.eq(false));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue