Some formatting

This commit is contained in:
Dessalines 2021-04-23 02:40:10 -04:00
parent 51e181c529
commit ef7fe7586b
7 changed files with 26 additions and 9 deletions

View file

@ -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};

View file

@ -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,

View file

@ -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);

View file

@ -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);

View file

@ -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};

View file

@ -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<T: MaybeOptional<bool>>(mut self, show_bot_accounts: T) -> Self {
self.show_bot_accounts = show_bot_accounts.get_optional();
self
}

View file

@ -238,7 +238,7 @@ impl<'a> PostQueryBuilder<'a> {
}
pub fn show_bot_accounts<T: MaybeOptional<bool>>(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));
};