Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/api/src/site/mod_log.rs
Expand Up @@ -55,10 +55,15 @@ pub async fn get_mod_log(
data.mod_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 {
community_id,
mod_person_id,
other_person_id,
post_id,
comment_id,
page: data.page,
limit: data.limit,
hide_modlog_names,
Expand Down
2 changes: 2 additions & 0 deletions crates/api_common/src/site.rs
Expand Up @@ -118,6 +118,8 @@ pub struct GetModlog {
pub limit: Option<i64>,
pub type_: Option<ModlogActionType>,
pub other_person_id: Option<PersonId>,
pub post_id: Option<PostId>,
pub comment_id: Option<CommentId>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
4 changes: 4 additions & 0 deletions crates/db_views_moderator/src/mod_feature_post_view.rs
Expand Up @@ -51,6 +51,10 @@ impl ModFeaturePostView {
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)?;

query
Expand Down
4 changes: 4 additions & 0 deletions crates/db_views_moderator/src/mod_lock_post_view.rs
Expand Up @@ -52,6 +52,10 @@ impl ModLockPostView {
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)?;

query
Expand Down
4 changes: 4 additions & 0 deletions crates/db_views_moderator/src/mod_remove_comment_view.rs
Expand Up @@ -54,6 +54,10 @@ impl ModRemoveCommentView {
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)?;

query
Expand Down
4 changes: 4 additions & 0 deletions crates/db_views_moderator/src/mod_remove_post_view.rs
Expand Up @@ -52,6 +52,10 @@ impl ModRemovePostView {
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)?;

query
Expand Down
4 changes: 3 additions & 1 deletion crates/db_views_moderator/src/structs.rs
@@ -1,7 +1,7 @@
#[cfg(feature = "full")]
use diesel::Queryable;
use lemmy_db_schema::{
newtypes::{CommunityId, PersonId},
newtypes::{CommentId, CommunityId, PersonId, PostId},
source::{
comment::Comment,
community::Community,
Expand Down Expand Up @@ -228,6 +228,8 @@ pub struct ModlogListParams {
pub community_id: Option<CommunityId>,
pub mod_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 limit: Option<i64>,
pub hide_modlog_names: bool,
Expand Down