mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 03:11:32 +00:00
Add Modlog Filters (#2313)
* Fix crash running locally on windows. * Add support for filtering mod logs * Refactor cleanup * Clippy fix * Condense match statements * Clippy fix 2
This commit is contained in:
parent
08a797c986
commit
21455d6b73
26 changed files with 543 additions and 302 deletions
|
@ -2,7 +2,18 @@ use crate::Perform;
|
|||
use actix_web::web::Data;
|
||||
use lemmy_api_common::{
|
||||
site::{GetModlog, GetModlogResponse},
|
||||
utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt},
|
||||
utils::{
|
||||
blocking,
|
||||
check_private_instance,
|
||||
get_local_user_view_from_jwt_opt,
|
||||
is_admin,
|
||||
is_mod_or_admin,
|
||||
},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
source::site::Site,
|
||||
ModlogActionType,
|
||||
};
|
||||
use lemmy_db_views_moderator::structs::{
|
||||
AdminPurgeCommentView,
|
||||
|
@ -20,9 +31,11 @@ use lemmy_db_views_moderator::structs::{
|
|||
ModRemovePostView,
|
||||
ModStickyPostView,
|
||||
ModTransferCommunityView,
|
||||
ModlogListParams,
|
||||
};
|
||||
use lemmy_utils::{error::LemmyError, ConnectionId};
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use ModlogActionType::*;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for GetModlog {
|
||||
|
@ -42,55 +55,123 @@ impl Perform for GetModlog {
|
|||
|
||||
check_private_instance(&local_user_view, context.pool()).await?;
|
||||
|
||||
let type_ = data.type_.unwrap_or(All);
|
||||
let community_id = data.community_id;
|
||||
let mod_person_id = data.mod_person_id;
|
||||
let page = data.page;
|
||||
let limit = data.limit;
|
||||
let removed_posts = blocking(context.pool(), move |conn| {
|
||||
ModRemovePostView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
|
||||
let locked_posts = blocking(context.pool(), move |conn| {
|
||||
ModLockPostView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let site = blocking(context.pool(), Site::read_local_site).await??;
|
||||
let (local_person_id, is_admin) = match local_user_view {
|
||||
Some(s) => (s.person.id, is_admin(&s).is_ok()),
|
||||
None => (PersonId(-1), false),
|
||||
};
|
||||
let community_id_value = match community_id {
|
||||
Some(s) => s,
|
||||
None => CommunityId(-1),
|
||||
};
|
||||
let is_mod_of_community = data.community_id.is_some()
|
||||
&& is_mod_or_admin(context.pool(), local_person_id, community_id_value)
|
||||
.await
|
||||
.is_ok();
|
||||
let hide_modlog_names = site.hide_modlog_mod_names && !is_mod_of_community && !is_admin;
|
||||
|
||||
let stickied_posts = blocking(context.pool(), move |conn| {
|
||||
ModStickyPostView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let mod_person_id = if hide_modlog_names {
|
||||
None
|
||||
} else {
|
||||
data.mod_person_id
|
||||
};
|
||||
let other_person_id = data.other_person_id;
|
||||
let params = ModlogListParams {
|
||||
community_id,
|
||||
mod_person_id,
|
||||
other_person_id,
|
||||
page: data.page,
|
||||
limit: data.limit,
|
||||
hide_modlog_names,
|
||||
};
|
||||
let removed_posts = match type_ {
|
||||
All | ModRemovePost => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModRemovePostView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let removed_comments = blocking(context.pool(), move |conn| {
|
||||
ModRemoveCommentView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let locked_posts = match type_ {
|
||||
All | ModLockPost => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModLockPostView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let banned_from_community = blocking(context.pool(), move |conn| {
|
||||
ModBanFromCommunityView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let stickied_posts = match type_ {
|
||||
All | ModStickyPost => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModStickyPostView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let added_to_community = blocking(context.pool(), move |conn| {
|
||||
ModAddCommunityView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let removed_comments = match type_ {
|
||||
All | ModRemoveComment => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModRemoveCommentView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let transferred_to_community = blocking(context.pool(), move |conn| {
|
||||
ModTransferCommunityView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let banned_from_community = match type_ {
|
||||
All | ModBanFromCommunity => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModBanFromCommunityView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let hidden_communities = blocking(context.pool(), move |conn| {
|
||||
ModHideCommunityView::list(conn, community_id, mod_person_id, page, limit)
|
||||
})
|
||||
.await??;
|
||||
let added_to_community = match type_ {
|
||||
All | ModAddCommunity => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModAddCommunityView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let transferred_to_community = match type_ {
|
||||
All | ModTransferCommunity => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModTransferCommunityView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
let hidden_communities = match type_ {
|
||||
All | ModHideCommunity if other_person_id.is_none() => {
|
||||
blocking(context.pool(), move |conn| {
|
||||
ModHideCommunityView::list(conn, params)
|
||||
})
|
||||
.await??
|
||||
}
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
// These arrays are only for the full modlog, when a community isn't given
|
||||
let (
|
||||
removed_communities,
|
||||
banned,
|
||||
added,
|
||||
removed_communities,
|
||||
admin_purged_persons,
|
||||
admin_purged_communities,
|
||||
admin_purged_posts,
|
||||
|
@ -98,13 +179,44 @@ impl Perform for GetModlog {
|
|||
) = if data.community_id.is_none() {
|
||||
blocking(context.pool(), move |conn| {
|
||||
Ok((
|
||||
ModRemoveCommunityView::list(conn, mod_person_id, page, limit)?,
|
||||
ModBanView::list(conn, mod_person_id, page, limit)?,
|
||||
ModAddView::list(conn, mod_person_id, page, limit)?,
|
||||
AdminPurgePersonView::list(conn, mod_person_id, page, limit)?,
|
||||
AdminPurgeCommunityView::list(conn, mod_person_id, page, limit)?,
|
||||
AdminPurgePostView::list(conn, mod_person_id, page, limit)?,
|
||||
AdminPurgeCommentView::list(conn, mod_person_id, page, limit)?,
|
||||
match type_ {
|
||||
All | ModBan => ModBanView::list(conn, params)?,
|
||||
_ => Default::default(),
|
||||
},
|
||||
match type_ {
|
||||
All | ModAdd => ModAddView::list(conn, params)?,
|
||||
_ => Default::default(),
|
||||
},
|
||||
match type_ {
|
||||
All | ModRemoveCommunity if other_person_id.is_none() => {
|
||||
ModRemoveCommunityView::list(conn, params)?
|
||||
}
|
||||
_ => Default::default(),
|
||||
},
|
||||
match type_ {
|
||||
All | AdminPurgePerson if other_person_id.is_none() => {
|
||||
AdminPurgePersonView::list(conn, params)?
|
||||
}
|
||||
_ => Default::default(),
|
||||
},
|
||||
match type_ {
|
||||
All | AdminPurgeCommunity if other_person_id.is_none() => {
|
||||
AdminPurgeCommunityView::list(conn, params)?
|
||||
}
|
||||
_ => Default::default(),
|
||||
},
|
||||
match type_ {
|
||||
All | AdminPurgePost if other_person_id.is_none() => {
|
||||
AdminPurgePostView::list(conn, params)?
|
||||
}
|
||||
_ => Default::default(),
|
||||
},
|
||||
match type_ {
|
||||
All | AdminPurgeComment if other_person_id.is_none() => {
|
||||
AdminPurgeCommentView::list(conn, params)?
|
||||
}
|
||||
_ => Default::default(),
|
||||
},
|
||||
)) as Result<_, LemmyError>
|
||||
})
|
||||
.await??
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::sensitive::Sensitive;
|
|||
use lemmy_db_schema::{
|
||||
newtypes::{CommentId, CommunityId, PersonId, PostId},
|
||||
ListingType,
|
||||
ModlogActionType,
|
||||
SearchType,
|
||||
SortType,
|
||||
};
|
||||
|
@ -83,6 +84,8 @@ pub struct GetModlog {
|
|||
pub page: Option<i64>,
|
||||
pub limit: Option<i64>,
|
||||
pub auth: Option<Sensitive<String>>,
|
||||
pub type_: Option<ModlogActionType>,
|
||||
pub other_person_id: Option<PersonId>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
|
@ -122,6 +125,7 @@ pub struct CreateSite {
|
|||
pub default_theme: Option<String>,
|
||||
pub default_post_listing_type: Option<String>,
|
||||
pub auth: Sensitive<String>,
|
||||
pub hide_modlog_mod_names: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
|
@ -143,6 +147,7 @@ pub struct EditSite {
|
|||
pub default_post_listing_type: Option<String>,
|
||||
pub legal_information: Option<String>,
|
||||
pub auth: Sensitive<String>,
|
||||
pub hide_modlog_mod_names: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
|
|
|
@ -76,6 +76,7 @@ impl PerformCrud for CreateSite {
|
|||
public_key: Some(keypair.public_key),
|
||||
default_theme: data.default_theme.clone(),
|
||||
default_post_listing_type: data.default_post_listing_type.clone(),
|
||||
hide_modlog_mod_names: data.hide_modlog_mod_names,
|
||||
..SiteForm::default()
|
||||
};
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ impl PerformCrud for EditSite {
|
|||
default_theme: data.default_theme.clone(),
|
||||
default_post_listing_type: data.default_post_listing_type.clone(),
|
||||
legal_information,
|
||||
hide_modlog_mod_names: data.hide_modlog_mod_names,
|
||||
..SiteForm::default()
|
||||
};
|
||||
|
||||
|
|
|
@ -71,3 +71,23 @@ pub enum SubscribedType {
|
|||
NotSubscribed,
|
||||
Pending,
|
||||
}
|
||||
|
||||
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
|
||||
pub enum ModlogActionType {
|
||||
All,
|
||||
ModRemovePost,
|
||||
ModLockPost,
|
||||
ModStickyPost,
|
||||
ModRemoveComment,
|
||||
ModRemoveCommunity,
|
||||
ModBanFromCommunity,
|
||||
ModAddCommunity,
|
||||
ModTransferCommunity,
|
||||
ModAdd,
|
||||
ModBan,
|
||||
ModHideCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePost,
|
||||
AdminPurgeComment,
|
||||
}
|
||||
|
|
|
@ -477,6 +477,7 @@ table! {
|
|||
default_theme -> Text,
|
||||
default_post_listing_type -> Text,
|
||||
legal_information -> Nullable<Text>,
|
||||
hide_modlog_mod_names -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ pub struct Site {
|
|||
pub default_theme: String,
|
||||
pub default_post_listing_type: String,
|
||||
pub legal_information: Option<String>,
|
||||
pub hide_modlog_mod_names: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -61,4 +62,5 @@ pub struct SiteForm {
|
|||
pub default_theme: Option<String>,
|
||||
pub default_post_listing_type: Option<String>,
|
||||
pub legal_information: Option<Option<String>>,
|
||||
pub hide_modlog_mod_names: Option<bool>,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::AdminPurgeCommentView;
|
||||
use crate::structs::{AdminPurgeCommentView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -12,30 +12,33 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type AdminPurgeCommentViewTuple = (AdminPurgeComment, PersonSafe, Post);
|
||||
type AdminPurgeCommentViewTuple = (AdminPurgeComment, Option<PersonSafe>, Post);
|
||||
|
||||
impl AdminPurgeCommentView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
admin_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = admin_purge_comment::admin_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
|
||||
let mut query = admin_purge_comment::table
|
||||
.inner_join(person::table.on(admin_purge_comment::admin_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(post::table)
|
||||
.select((
|
||||
admin_purge_comment::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
post::all_columns,
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(admin_person_id) = admin_person_id {
|
||||
if let Some(admin_person_id) = params.mod_person_id {
|
||||
query = query.filter(admin_purge_comment::admin_person_id.eq(admin_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -43,7 +46,8 @@ impl AdminPurgeCommentView {
|
|||
.order_by(admin_purge_comment::when_.desc())
|
||||
.load::<AdminPurgeCommentViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::AdminPurgeCommunityView;
|
||||
use crate::structs::{AdminPurgeCommunityView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -11,28 +11,31 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type AdminPurgeCommunityViewTuple = (AdminPurgeCommunity, PersonSafe);
|
||||
type AdminPurgeCommunityViewTuple = (AdminPurgeCommunity, Option<PersonSafe>);
|
||||
|
||||
impl AdminPurgeCommunityView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
admin_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = admin_purge_community::admin_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
|
||||
let mut query = admin_purge_community::table
|
||||
.inner_join(person::table.on(admin_purge_community::admin_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.select((
|
||||
admin_purge_community::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(admin_person_id) = admin_person_id {
|
||||
if let Some(admin_person_id) = params.mod_person_id {
|
||||
query = query.filter(admin_purge_community::admin_person_id.eq(admin_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -40,7 +43,8 @@ impl AdminPurgeCommunityView {
|
|||
.order_by(admin_purge_community::when_.desc())
|
||||
.load::<AdminPurgeCommunityViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::AdminPurgePersonView;
|
||||
use crate::structs::{AdminPurgePersonView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -11,28 +11,30 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type AdminPurgePersonViewTuple = (AdminPurgePerson, PersonSafe);
|
||||
type AdminPurgePersonViewTuple = (AdminPurgePerson, Option<PersonSafe>);
|
||||
|
||||
impl AdminPurgePersonView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
admin_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = admin_purge_person::admin_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = admin_purge_person::table
|
||||
.inner_join(person::table.on(admin_purge_person::admin_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.select((
|
||||
admin_purge_person::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(admin_person_id) = admin_person_id {
|
||||
if let Some(admin_person_id) = params.mod_person_id {
|
||||
query = query.filter(admin_purge_person::admin_person_id.eq(admin_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -40,7 +42,8 @@ impl AdminPurgePersonView {
|
|||
.order_by(admin_purge_person::when_.desc())
|
||||
.load::<AdminPurgePersonViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::AdminPurgePostView;
|
||||
use crate::structs::{AdminPurgePostView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -12,30 +12,32 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type AdminPurgePostViewTuple = (AdminPurgePost, PersonSafe, CommunitySafe);
|
||||
type AdminPurgePostViewTuple = (AdminPurgePost, Option<PersonSafe>, CommunitySafe);
|
||||
|
||||
impl AdminPurgePostView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
admin_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = admin_purge_post::admin_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = admin_purge_post::table
|
||||
.inner_join(person::table.on(admin_purge_post::admin_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(community::table)
|
||||
.select((
|
||||
admin_purge_post::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(admin_person_id) = admin_person_id {
|
||||
if let Some(admin_person_id) = params.mod_person_id {
|
||||
query = query.filter(admin_purge_post::admin_person_id.eq(admin_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -43,7 +45,8 @@ impl AdminPurgePostView {
|
|||
.order_by(admin_purge_post::when_.desc())
|
||||
.load::<AdminPurgePostViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::structs::ModAddCommunityView;
|
||||
use crate::structs::{ModAddCommunityView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_add_community, person, person_alias_1},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
|
@ -12,39 +12,49 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModAddCommunityViewTuple = (ModAddCommunity, PersonSafe, CommunitySafe, PersonSafeAlias1);
|
||||
type ModAddCommunityViewTuple = (
|
||||
ModAddCommunity,
|
||||
Option<PersonSafe>,
|
||||
CommunitySafe,
|
||||
PersonSafeAlias1,
|
||||
);
|
||||
|
||||
impl ModAddCommunityView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_add_community::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_add_community::table
|
||||
.inner_join(person::table.on(mod_add_community::mod_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(community::table)
|
||||
.inner_join(
|
||||
person_alias_1::table.on(mod_add_community::other_person_id.eq(person_alias_1::id)),
|
||||
)
|
||||
.select((
|
||||
mod_add_community::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
Community::safe_columns_tuple(),
|
||||
PersonAlias1::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_add_community::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(mod_add_community::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -52,7 +62,8 @@ impl ModAddCommunityView {
|
|||
.order_by(mod_add_community::when_.desc())
|
||||
.load::<ModAddCommunityViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::ModAddView;
|
||||
use crate::structs::{ModAddView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -11,30 +11,36 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModAddViewTuple = (ModAdd, PersonSafe, PersonSafeAlias1);
|
||||
type ModAddViewTuple = (ModAdd, Option<PersonSafe>, PersonSafeAlias1);
|
||||
|
||||
impl ModAddView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_add::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_add::table
|
||||
.inner_join(person::table.on(mod_add::mod_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(person_alias_1::table.on(mod_add::other_person_id.eq(person_alias_1::id)))
|
||||
.select((
|
||||
mod_add::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
PersonAlias1::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_add::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -42,7 +48,8 @@ impl ModAddView {
|
|||
.order_by(mod_add::when_.desc())
|
||||
.load::<ModAddViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::structs::ModBanFromCommunityView;
|
||||
use crate::structs::{ModBanFromCommunityView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_ban_from_community, person, person_alias_1},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
|
@ -14,42 +14,47 @@ use lemmy_db_schema::{
|
|||
|
||||
type ModBanFromCommunityViewTuple = (
|
||||
ModBanFromCommunity,
|
||||
PersonSafe,
|
||||
Option<PersonSafe>,
|
||||
CommunitySafe,
|
||||
PersonSafeAlias1,
|
||||
);
|
||||
|
||||
impl ModBanFromCommunityView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_ban_from_community::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_ban_from_community::table
|
||||
.inner_join(person::table.on(mod_ban_from_community::mod_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(community::table)
|
||||
.inner_join(
|
||||
person_alias_1::table.on(mod_ban_from_community::other_person_id.eq(person_alias_1::id)),
|
||||
)
|
||||
.select((
|
||||
mod_ban_from_community::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
Community::safe_columns_tuple(),
|
||||
PersonAlias1::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_ban_from_community::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(mod_ban_from_community::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(mod_ban_from_community::other_person_id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -57,7 +62,8 @@ impl ModBanFromCommunityView {
|
|||
.order_by(mod_ban_from_community::when_.desc())
|
||||
.load::<ModBanFromCommunityViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::ModBanView;
|
||||
use crate::structs::{ModBanView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -11,30 +11,36 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModBanViewTuple = (ModBan, PersonSafe, PersonSafeAlias1);
|
||||
type ModBanViewTuple = (ModBan, Option<PersonSafe>, PersonSafeAlias1);
|
||||
|
||||
impl ModBanView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_ban::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_ban::table
|
||||
.inner_join(person::table.on(mod_ban::mod_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(person_alias_1::table.on(mod_ban::other_person_id.eq(person_alias_1::id)))
|
||||
.select((
|
||||
mod_ban::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
PersonAlias1::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_ban::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -42,7 +48,8 @@ impl ModBanView {
|
|||
.order_by(mod_ban::when_.desc())
|
||||
.load::<ModBanViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::structs::ModHideCommunityView;
|
||||
use crate::structs::{ModHideCommunityView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_hide_community, person},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
|
@ -12,36 +12,37 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModHideCommunityViewTuple = (ModHideCommunity, PersonSafe, CommunitySafe);
|
||||
type ModHideCommunityViewTuple = (ModHideCommunity, Option<PersonSafe>, CommunitySafe);
|
||||
|
||||
impl ModHideCommunityView {
|
||||
// Pass in mod_id as admin_id because only admins can do this action
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
admin_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_hide_community::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_hide_community::table
|
||||
.inner_join(person::table)
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(community::table.on(mod_hide_community::community_id.eq(community::id)))
|
||||
.select((
|
||||
mod_hide_community::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(mod_hide_community::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
if let Some(admin_id) = admin_id {
|
||||
if let Some(admin_id) = params.mod_person_id {
|
||||
query = query.filter(mod_hide_community::mod_person_id.eq(admin_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -49,7 +50,8 @@ impl ModHideCommunityView {
|
|||
.order_by(mod_hide_community::when_.desc())
|
||||
.load::<ModHideCommunityViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::structs::ModLockPostView;
|
||||
use crate::structs::{ModLockPostView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
schema::{community, mod_lock_post, person, post},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_lock_post, person, person_alias_1, post},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModLockPost,
|
||||
|
@ -13,37 +13,43 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModLockPostViewTuple = (ModLockPost, PersonSafe, Post, CommunitySafe);
|
||||
type ModLockPostViewTuple = (ModLockPost, Option<PersonSafe>, Post, CommunitySafe);
|
||||
|
||||
impl ModLockPostView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_lock_post::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_lock_post::table
|
||||
.inner_join(person::table)
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(post::table)
|
||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||
.inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id)))
|
||||
.select((
|
||||
mod_lock_post::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
post::all_columns,
|
||||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(post::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_lock_post::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -51,7 +57,8 @@ impl ModLockPostView {
|
|||
.order_by(mod_lock_post::when_.desc())
|
||||
.load::<ModLockPostViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::structs::ModRemoveCommentView;
|
||||
use crate::structs::{ModRemoveCommentView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
newtypes::PersonId,
|
||||
schema::{comment, community, mod_remove_comment, person, person_alias_1, post},
|
||||
source::{
|
||||
comment::Comment,
|
||||
|
@ -16,7 +16,7 @@ use lemmy_db_schema::{
|
|||
|
||||
type ModRemoveCommentViewTuple = (
|
||||
ModRemoveComment,
|
||||
PersonSafe,
|
||||
Option<PersonSafe>,
|
||||
Comment,
|
||||
PersonSafeAlias1,
|
||||
Post,
|
||||
|
@ -24,22 +24,23 @@ type ModRemoveCommentViewTuple = (
|
|||
);
|
||||
|
||||
impl ModRemoveCommentView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_remove_comment::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_remove_comment::table
|
||||
.inner_join(person::table)
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(comment::table)
|
||||
.inner_join(person_alias_1::table.on(comment::creator_id.eq(person_alias_1::id)))
|
||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||
.select((
|
||||
mod_remove_comment::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
comment::all_columns,
|
||||
PersonAlias1::safe_columns_tuple(),
|
||||
post::all_columns,
|
||||
|
@ -47,15 +48,19 @@ impl ModRemoveCommentView {
|
|||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(post::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_remove_comment::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -63,7 +68,8 @@ impl ModRemoveCommentView {
|
|||
.order_by(mod_remove_comment::when_.desc())
|
||||
.load::<ModRemoveCommentViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::structs::ModRemoveCommunityView;
|
||||
use crate::structs::{ModRemoveCommunityView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::PersonId,
|
||||
|
@ -12,30 +12,32 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModRemoveCommunityTuple = (ModRemoveCommunity, PersonSafe, CommunitySafe);
|
||||
type ModRemoveCommunityTuple = (ModRemoveCommunity, Option<PersonSafe>, CommunitySafe);
|
||||
|
||||
impl ModRemoveCommunityView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_remove_community::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_remove_community::table
|
||||
.inner_join(person::table)
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(community::table)
|
||||
.select((
|
||||
mod_remove_community::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_remove_community::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -43,7 +45,8 @@ impl ModRemoveCommunityView {
|
|||
.order_by(mod_remove_community::when_.desc())
|
||||
.load::<ModRemoveCommunityTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::structs::ModRemovePostView;
|
||||
use crate::structs::{ModRemovePostView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
schema::{community, mod_remove_post, person, post},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_remove_post, person, person_alias_1, post},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModRemovePost,
|
||||
|
@ -13,37 +13,43 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModRemovePostViewTuple = (ModRemovePost, PersonSafe, Post, CommunitySafe);
|
||||
type ModRemovePostViewTuple = (ModRemovePost, Option<PersonSafe>, Post, CommunitySafe);
|
||||
|
||||
impl ModRemovePostView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_remove_post::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_remove_post::table
|
||||
.inner_join(person::table)
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(post::table)
|
||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||
.inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id)))
|
||||
.select((
|
||||
mod_remove_post::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
post::all_columns,
|
||||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(post::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_remove_post::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -51,7 +57,8 @@ impl ModRemovePostView {
|
|||
.order_by(mod_remove_post::when_.desc())
|
||||
.load::<ModRemovePostViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::structs::ModStickyPostView;
|
||||
use crate::structs::{ModStickyPostView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
schema::{community, mod_sticky_post, person, post},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_sticky_post, person, person_alias_1, post},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
moderator::ModStickyPost,
|
||||
|
@ -13,37 +13,43 @@ use lemmy_db_schema::{
|
|||
utils::limit_and_offset,
|
||||
};
|
||||
|
||||
type ModStickyPostViewTuple = (ModStickyPost, PersonSafe, Post, CommunitySafe);
|
||||
type ModStickyPostViewTuple = (ModStickyPost, Option<PersonSafe>, Post, CommunitySafe);
|
||||
|
||||
impl ModStickyPostView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_sticky_post::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_sticky_post::table
|
||||
.inner_join(person::table)
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(post::table)
|
||||
.inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id)))
|
||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||
.select((
|
||||
mod_sticky_post::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
post::all_columns,
|
||||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(post::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_sticky_post::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -51,7 +57,8 @@ impl ModStickyPostView {
|
|||
.order_by(mod_sticky_post::when_.desc())
|
||||
.load::<ModStickyPostViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::structs::ModTransferCommunityView;
|
||||
use crate::structs::{ModTransferCommunityView, ModlogListParams};
|
||||
use diesel::{result::Error, *};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_transfer_community, person, person_alias_1},
|
||||
source::{
|
||||
community::{Community, CommunitySafe},
|
||||
|
@ -14,42 +14,47 @@ use lemmy_db_schema::{
|
|||
|
||||
type ModTransferCommunityViewTuple = (
|
||||
ModTransferCommunity,
|
||||
PersonSafe,
|
||||
Option<PersonSafe>,
|
||||
CommunitySafe,
|
||||
PersonSafeAlias1,
|
||||
);
|
||||
|
||||
impl ModTransferCommunityView {
|
||||
pub fn list(
|
||||
conn: &PgConnection,
|
||||
community_id: Option<CommunityId>,
|
||||
mod_person_id: Option<PersonId>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let admin_names_join = mod_transfer_community::mod_person_id
|
||||
.eq(person::id)
|
||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||
let mut query = mod_transfer_community::table
|
||||
.inner_join(person::table.on(mod_transfer_community::mod_person_id.eq(person::id)))
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.inner_join(community::table)
|
||||
.inner_join(
|
||||
person_alias_1::table.on(mod_transfer_community::other_person_id.eq(person_alias_1::id)),
|
||||
)
|
||||
.select((
|
||||
mod_transfer_community::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
Person::safe_columns_tuple().nullable(),
|
||||
Community::safe_columns_tuple(),
|
||||
PersonAlias1::safe_columns_tuple(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
if let Some(mod_person_id) = mod_person_id {
|
||||
if let Some(mod_person_id) = params.mod_person_id {
|
||||
query = query.filter(mod_transfer_community::mod_person_id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
if let Some(community_id) = community_id {
|
||||
if let Some(community_id) = params.community_id {
|
||||
query = query.filter(mod_transfer_community::community_id.eq(community_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
if let Some(other_person_id) = params.other_person_id {
|
||||
query = query.filter(person_alias_1::id.eq(other_person_id));
|
||||
};
|
||||
|
||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||
|
||||
let res = query
|
||||
.limit(limit)
|
||||
|
@ -57,7 +62,8 @@ impl ModTransferCommunityView {
|
|||
.order_by(mod_transfer_community::when_.desc())
|
||||
.load::<ModTransferCommunityViewTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(res))
|
||||
let results = Self::from_tuple_to_vec(res);
|
||||
Ok(results)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +1,35 @@
|
|||
use lemmy_db_schema::source::{
|
||||
comment::Comment,
|
||||
community::CommunitySafe,
|
||||
moderator::{
|
||||
AdminPurgeComment,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgePost,
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModBan,
|
||||
ModBanFromCommunity,
|
||||
ModHideCommunity,
|
||||
ModLockPost,
|
||||
ModRemoveComment,
|
||||
ModRemoveCommunity,
|
||||
ModRemovePost,
|
||||
ModStickyPost,
|
||||
ModTransferCommunity,
|
||||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, PersonId},
|
||||
source::{
|
||||
comment::Comment,
|
||||
community::CommunitySafe,
|
||||
moderator::{
|
||||
AdminPurgeComment,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgePost,
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModBan,
|
||||
ModBanFromCommunity,
|
||||
ModHideCommunity,
|
||||
ModLockPost,
|
||||
ModRemoveComment,
|
||||
ModRemoveCommunity,
|
||||
ModRemovePost,
|
||||
ModStickyPost,
|
||||
ModTransferCommunity,
|
||||
},
|
||||
person::{PersonSafe, PersonSafeAlias1},
|
||||
post::Post,
|
||||
},
|
||||
person::{PersonSafe, PersonSafeAlias1},
|
||||
post::Post,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModAddCommunityView {
|
||||
pub mod_add_community: ModAddCommunity,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub community: CommunitySafe,
|
||||
pub modded_person: PersonSafeAlias1,
|
||||
}
|
||||
|
@ -34,14 +37,14 @@ pub struct ModAddCommunityView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModAddView {
|
||||
pub mod_add: ModAdd,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub modded_person: PersonSafeAlias1,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModBanFromCommunityView {
|
||||
pub mod_ban_from_community: ModBanFromCommunity,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub community: CommunitySafe,
|
||||
pub banned_person: PersonSafeAlias1,
|
||||
}
|
||||
|
@ -49,21 +52,21 @@ pub struct ModBanFromCommunityView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModBanView {
|
||||
pub mod_ban: ModBan,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub banned_person: PersonSafeAlias1,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModHideCommunityView {
|
||||
pub mod_hide_community: ModHideCommunity,
|
||||
pub admin: PersonSafe,
|
||||
pub admin: Option<PersonSafe>,
|
||||
pub community: CommunitySafe,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModLockPostView {
|
||||
pub mod_lock_post: ModLockPost,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub post: Post,
|
||||
pub community: CommunitySafe,
|
||||
}
|
||||
|
@ -71,7 +74,7 @@ pub struct ModLockPostView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModRemoveCommentView {
|
||||
pub mod_remove_comment: ModRemoveComment,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub comment: Comment,
|
||||
pub commenter: PersonSafeAlias1,
|
||||
pub post: Post,
|
||||
|
@ -81,14 +84,14 @@ pub struct ModRemoveCommentView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModRemoveCommunityView {
|
||||
pub mod_remove_community: ModRemoveCommunity,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub community: CommunitySafe,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModRemovePostView {
|
||||
pub mod_remove_post: ModRemovePost,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub post: Post,
|
||||
pub community: CommunitySafe,
|
||||
}
|
||||
|
@ -96,7 +99,7 @@ pub struct ModRemovePostView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModStickyPostView {
|
||||
pub mod_sticky_post: ModStickyPost,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub post: Post,
|
||||
pub community: CommunitySafe,
|
||||
}
|
||||
|
@ -104,7 +107,7 @@ pub struct ModStickyPostView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ModTransferCommunityView {
|
||||
pub mod_transfer_community: ModTransferCommunity,
|
||||
pub moderator: PersonSafe,
|
||||
pub moderator: Option<PersonSafe>,
|
||||
pub community: CommunitySafe,
|
||||
pub modded_person: PersonSafeAlias1,
|
||||
}
|
||||
|
@ -112,25 +115,35 @@ pub struct ModTransferCommunityView {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AdminPurgeCommentView {
|
||||
pub admin_purge_comment: AdminPurgeComment,
|
||||
pub admin: PersonSafe,
|
||||
pub admin: Option<PersonSafe>,
|
||||
pub post: Post,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AdminPurgeCommunityView {
|
||||
pub admin_purge_community: AdminPurgeCommunity,
|
||||
pub admin: PersonSafe,
|
||||
pub admin: Option<PersonSafe>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AdminPurgePersonView {
|
||||
pub admin_purge_person: AdminPurgePerson,
|
||||
pub admin: PersonSafe,
|
||||
pub admin: Option<PersonSafe>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AdminPurgePostView {
|
||||
pub admin_purge_post: AdminPurgePost,
|
||||
pub admin: PersonSafe,
|
||||
pub admin: Option<PersonSafe>,
|
||||
pub community: CommunitySafe,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
|
||||
pub struct ModlogListParams {
|
||||
pub community_id: Option<CommunityId>,
|
||||
pub mod_person_id: Option<PersonId>,
|
||||
pub other_person_id: Option<PersonId>,
|
||||
pub page: Option<i64>,
|
||||
pub limit: Option<i64>,
|
||||
pub hide_modlog_names: bool,
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
alter table site drop column hide_modlog_mod_names;
|
|
@ -0,0 +1 @@
|
|||
alter table site add column hide_modlog_mod_names boolean default true NOT NULL;
|
|
@ -70,6 +70,7 @@ async fn main() -> Result<(), LemmyError> {
|
|||
let manager = ConnectionManager::<PgConnection>::new(&db_url);
|
||||
let pool = Pool::builder()
|
||||
.max_size(settings.database.pool_size)
|
||||
.min_idle(Some(1))
|
||||
.build(manager)
|
||||
.unwrap_or_else(|_| panic!("Error connecting to {}", db_url));
|
||||
|
||||
|
|
Loading…
Reference in a new issue