From: Nutomic Date: Fri, 4 Aug 2023 15:36:36 +0000 (+0200) Subject: Remove unused db view options (#3787) X-Git-Url: http://these/git/readmes/%24%7B%60data:application/%7B%60%24%7BghostArchiveUrl%7D/search?a=commitdiff_plain;h=66ac8100d98d721136205ed0de2a1d7abb1e0d1d;p=lemmy.git Remove unused db view options (#3787) * Remove unused db view options * fix tests * ci --- diff --git a/crates/apub/src/api/read_person.rs b/crates/apub/src/api/read_person.rs index 5d3c73c3..e5924dc8 100644 --- a/crates/apub/src/api/read_person.rs +++ b/crates/apub/src/api/read_person.rs @@ -65,7 +65,7 @@ pub async fn read_person( saved_only, local_user: local_user_view.as_ref(), community_id, - is_profile_view: Some(true), + is_profile_view: true, page, limit, creator_id, @@ -75,14 +75,13 @@ pub async fn read_person( .await?; let comments = CommentQuery { - local_user: (local_user_view.as_ref()), - sort: (sort.map(post_to_comment_sort_type)), - saved_only: (saved_only), - show_deleted_and_removed: (Some(false)), - community_id: (community_id), - is_profile_view: Some(true), - page: (page), - limit: (limit), + local_user: local_user_view.as_ref(), + sort: sort.map(post_to_comment_sort_type), + saved_only, + community_id, + is_profile_view: true, + page, + limit, creator_id, ..Default::default() } diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 26787cce..4cad1e74 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -195,7 +195,6 @@ fn queries<'a>() -> Queries< query = query.filter(comment_saved::comment_id.is_not_null()); } - let is_profile_view = options.is_profile_view.unwrap_or(false); let is_creator = options.creator_id == options.local_user.map(|l| l.person.id); // only show deleted comments to creator if !is_creator { @@ -204,7 +203,7 @@ fn queries<'a>() -> Queries< let is_admin = options.local_user.map(|l| l.person.admin).unwrap_or(false); // only show removed comments to admin when viewing user profile - if !(is_profile_view && is_admin) { + if !(options.is_profile_view && is_admin) { query = query.filter(comment::removed.eq(false)); } @@ -310,8 +309,7 @@ pub struct CommentQuery<'a> { pub local_user: Option<&'a LocalUserView>, pub search_term: Option, pub saved_only: Option, - pub is_profile_view: Option, - pub show_deleted_and_removed: Option, + pub is_profile_view: bool, pub page: Option, pub limit: Option, pub max_depth: Option, diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 3243bca8..30de18b6 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -212,7 +212,6 @@ fn queries<'a>() -> Queries< ) .select(selection); - let is_profile_view = options.is_profile_view.unwrap_or(false); let is_creator = options.creator_id == options.local_user.map(|l| l.person.id); // only show deleted posts to creator if is_creator { @@ -223,7 +222,7 @@ fn queries<'a>() -> Queries< let is_admin = options.local_user.map(|l| l.person.admin).unwrap_or(false); // only show removed posts to admin when viewing user profile - if !(is_profile_view && is_admin) { + if !(options.is_profile_view && is_admin) { query = query .filter(community::removed.eq(false)) .filter(post::removed.eq(false)); @@ -428,7 +427,7 @@ pub struct PostQuery<'a> { pub url_search: Option, pub saved_only: Option, pub moderator_view: Option, - pub is_profile_view: Option, + pub is_profile_view: bool, pub page: Option, pub limit: Option, } @@ -919,7 +918,7 @@ mod tests { let post_listings_is_admin = PostQuery { sort: Some(SortType::New), local_user: Some(&data.local_user_view), - is_profile_view: Some(true), + is_profile_view: true, ..Default::default() } .list(pool)