From: Dessalines Date: Fri, 23 Apr 2021 06:40:10 +0000 (-0400) Subject: Some formatting X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%24%7B%60data:application/static/%7B%60https:/%7BpictrsAvatarThumbnail%28community.icon%29%7D?a=commitdiff_plain;h=ef7fe7586b6b88e5b5da1f6f5737fd5c2435e3ab;p=lemmy.git Some formatting --- 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)); };