From ef7fe7586b6b88e5b5da1f6f5737fd5c2435e3ab Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 23 Apr 2021 02:40:10 -0400 Subject: [PATCH] Some formatting --- crates/api_crud/src/comment/read.rs | 7 ++++++- crates/api_crud/src/post/read.rs | 8 +++++++- crates/api_crud/src/site/create.rs | 2 +- crates/api_crud/src/site/read.rs | 2 +- crates/api_crud/src/user/read.rs | 8 +++++++- crates/db_views/src/comment_view.rs | 4 ++-- crates/db_views/src/post_view.rs | 4 ++-- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/crates/api_crud/src/comment/read.rs b/crates/api_crud/src/comment/read.rs index ceed0095..f82b9748 100644 --- a/crates/api_crud/src/comment/read.rs +++ b/crates/api_crud/src/comment/read.rs @@ -1,6 +1,11 @@ use crate::PerformCrud; use actix_web::web::Data; -use lemmy_api_common::{blocking, comment::*, get_local_user_view_from_jwt_opt, user_show_bot_accounts}; +use lemmy_api_common::{ + blocking, + comment::*, + get_local_user_view_from_jwt_opt, + user_show_bot_accounts, +}; use lemmy_db_queries::{from_opt_str_to_opt_enum, ListingType, SortType}; use lemmy_db_views::comment_view::CommentQueryBuilder; use lemmy_utils::{ApiError, ConnectionId, LemmyError}; diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index 858a878f..14c6cad5 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -1,6 +1,12 @@ use crate::PerformCrud; use actix_web::web::Data; -use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, post::*, user_show_bot_accounts, user_show_nsfw}; +use lemmy_api_common::{ + blocking, + get_local_user_view_from_jwt_opt, + post::*, + user_show_bot_accounts, + user_show_nsfw, +}; use lemmy_db_queries::{from_opt_str_to_opt_enum, ListingType, SortType}; use lemmy_db_views::{ comment_view::CommentQueryBuilder, diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index dc6e649d..2b876c2f 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -67,7 +67,7 @@ impl PerformCrud for CreateSite { open_registration: data.open_registration, enable_nsfw: data.enable_nsfw, updated: None, - community_creation_admin_only: Some(data.community_creation_admin_only), + community_creation_admin_only: data.community_creation_admin_only, }; let create_site = move |conn: &'_ _| Site::create(conn, &site_form); diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index fb409f1c..9b73c12f 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -51,7 +51,7 @@ impl PerformCrud for GetSite { open_registration: None, enable_nsfw: None, auth: login_response.jwt, - community_creation_admin_only: false, + community_creation_admin_only: None, }; create_site.perform(context, websocket_id).await?; info!("Site {} created", setup.site_name); diff --git a/crates/api_crud/src/user/read.rs b/crates/api_crud/src/user/read.rs index f3276416..81194d1e 100644 --- a/crates/api_crud/src/user/read.rs +++ b/crates/api_crud/src/user/read.rs @@ -1,6 +1,12 @@ use crate::PerformCrud; use actix_web::web::Data; -use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, person::*, user_show_nsfw, user_show_bot_accounts}; +use lemmy_api_common::{ + blocking, + get_local_user_view_from_jwt_opt, + person::*, + user_show_bot_accounts, + user_show_nsfw, +}; use lemmy_db_queries::{from_opt_str_to_opt_enum, source::person::Person_, SortType}; use lemmy_db_schema::source::person::*; use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder}; diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 8c6d44af..7424d9d6 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -264,8 +264,8 @@ impl<'a> CommentQueryBuilder<'a> { self } - pub fn show_bot_accounts(mut self, show_bot_accounts: bool) -> Self { - self.show_bot_accounts = show_bot_accounts; + pub fn show_bot_accounts>(mut self, show_bot_accounts: T) -> Self { + self.show_bot_accounts = show_bot_accounts.get_optional(); self } diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 192517e0..42393575 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -238,7 +238,7 @@ impl<'a> PostQueryBuilder<'a> { } pub fn show_bot_accounts>(mut self, show_bot_accounts: T) -> Self { - self.show_bot_accounts = show_bot_accounts; + self.show_bot_accounts = show_bot_accounts.get_optional(); self } @@ -360,7 +360,7 @@ impl<'a> PostQueryBuilder<'a> { .filter(community::nsfw.eq(false)); }; - if !self.show_bot_accounts { + if !self.show_bot_accounts.unwrap_or(true) { query = query.filter(person::bot_account.eq(false)); }; -- 2.44.1