View mod history for a post or comment. Fixes #4162 (#4491)

This commit is contained in:
Dessalines 2024-03-04 11:42:25 -05:00 committed by GitHub
parent 3c358e5b0b
commit 65da4e7dbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 26 additions and 1 deletions

View file

@ -55,10 +55,15 @@ pub async fn get_mod_log(
data.mod_person_id data.mod_person_id
}; };
let other_person_id = data.other_person_id; let other_person_id = data.other_person_id;
let post_id = data.post_id;
let comment_id = data.comment_id;
let params = ModlogListParams { let params = ModlogListParams {
community_id, community_id,
mod_person_id, mod_person_id,
other_person_id, other_person_id,
post_id,
comment_id,
page: data.page, page: data.page,
limit: data.limit, limit: data.limit,
hide_modlog_names, hide_modlog_names,

View file

@ -118,6 +118,8 @@ pub struct GetModlog {
pub limit: Option<i64>, pub limit: Option<i64>,
pub type_: Option<ModlogActionType>, pub type_: Option<ModlogActionType>,
pub other_person_id: Option<PersonId>, pub other_person_id: Option<PersonId>,
pub post_id: Option<PostId>,
pub comment_id: Option<CommentId>,
} }
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]

View file

@ -51,6 +51,10 @@ impl ModFeaturePostView {
query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
}; };
if let Some(post_id) = params.post_id {
query = query.filter(post::id.eq(post_id));
}
let (limit, offset) = limit_and_offset(params.page, params.limit)?; let (limit, offset) = limit_and_offset(params.page, params.limit)?;
query query

View file

@ -52,6 +52,10 @@ impl ModLockPostView {
query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
}; };
if let Some(post_id) = params.post_id {
query = query.filter(post::id.eq(post_id));
}
let (limit, offset) = limit_and_offset(params.page, params.limit)?; let (limit, offset) = limit_and_offset(params.page, params.limit)?;
query query

View file

@ -54,6 +54,10 @@ impl ModRemoveCommentView {
query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
}; };
if let Some(comment_id) = params.comment_id {
query = query.filter(comment::id.eq(comment_id));
}
let (limit, offset) = limit_and_offset(params.page, params.limit)?; let (limit, offset) = limit_and_offset(params.page, params.limit)?;
query query

View file

@ -52,6 +52,10 @@ impl ModRemovePostView {
query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
}; };
if let Some(post_id) = params.post_id {
query = query.filter(post::id.eq(post_id));
}
let (limit, offset) = limit_and_offset(params.page, params.limit)?; let (limit, offset) = limit_and_offset(params.page, params.limit)?;
query query

View file

@ -1,7 +1,7 @@
#[cfg(feature = "full")] #[cfg(feature = "full")]
use diesel::Queryable; use diesel::Queryable;
use lemmy_db_schema::{ use lemmy_db_schema::{
newtypes::{CommunityId, PersonId}, newtypes::{CommentId, CommunityId, PersonId, PostId},
source::{ source::{
comment::Comment, comment::Comment,
community::Community, community::Community,
@ -228,6 +228,8 @@ pub struct ModlogListParams {
pub community_id: Option<CommunityId>, pub community_id: Option<CommunityId>,
pub mod_person_id: Option<PersonId>, pub mod_person_id: Option<PersonId>,
pub other_person_id: Option<PersonId>, pub other_person_id: Option<PersonId>,
pub post_id: Option<PostId>,
pub comment_id: Option<CommentId>,
pub page: Option<i64>, pub page: Option<i64>,
pub limit: Option<i64>, pub limit: Option<i64>,
pub hide_modlog_names: bool, pub hide_modlog_names: bool,