From 5c35e97a75a669c4ebea5d3e533e616a19474921 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 30 Apr 2024 06:24:18 -0400 Subject: [PATCH] Dont show deleted / removed posts when searching. Fixes #4576 (#4671) * Dont show deleted / removed posts when searching. Fixes #4576 * Address PR comments. * Clean up comment removed also. --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> --- crates/db_views/src/comment_view.rs | 3 +-- crates/db_views/src/post_view.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 910c37406..ec4faf0e7 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -220,8 +220,7 @@ fn queries<'a>() -> Queries< query = query.filter( comment::content .ilike(fuzzy_search(&search_term)) - .and(comment::removed.eq(false)) - .and(comment::deleted.eq(false)), + .and(not(comment::removed.or(comment::deleted))), ); }; diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 257bcc76c..4c7ecd088 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -396,11 +396,13 @@ fn queries<'a>() -> Queries< if let Some(search_term) = &options.search_term { let searcher = fuzzy_search(search_term); - query = query.filter( - post::name - .ilike(searcher.clone()) - .or(post::body.ilike(searcher)), - ); + query = query + .filter( + post::name + .ilike(searcher.clone()) + .or(post::body.ilike(searcher)), + ) + .filter(not(post::removed.or(post::deleted))); } // If there is a content warning, show nsfw content by default.