View report history for a post or comment. Fixes #4190 (#4492)

pull/4502/head
Dessalines 2 months ago committed by GitHub
parent 36ad1868b3
commit 52155c74cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -16,6 +16,7 @@ pub async fn list_comment_reports(
local_user_view: LocalUserView,
) -> Result<Json<ListCommentReportsResponse>, LemmyError> {
let community_id = data.community_id;
let comment_id = data.comment_id;
let unresolved_only = data.unresolved_only.unwrap_or_default();
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
@ -24,6 +25,7 @@ pub async fn list_comment_reports(
let limit = data.limit;
let comment_reports = CommentReportQuery {
community_id,
comment_id,
unresolved_only,
page,
limit,

@ -16,6 +16,7 @@ pub async fn list_post_reports(
local_user_view: LocalUserView,
) -> Result<Json<ListPostReportsResponse>, LemmyError> {
let community_id = data.community_id;
let post_id = data.post_id;
let unresolved_only = data.unresolved_only.unwrap_or_default();
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
@ -24,6 +25,7 @@ pub async fn list_post_reports(
let limit = data.limit;
let post_reports = PostReportQuery {
community_id,
post_id,
unresolved_only,
page,
limit,

@ -161,6 +161,7 @@ pub struct ResolveCommentReport {
#[cfg_attr(feature = "full", ts(export))]
/// List comment reports.
pub struct ListCommentReports {
pub comment_id: Option<CommentId>,
pub page: Option<i64>,
pub limit: Option<i64>,
/// Only shows the unresolved reports

@ -229,6 +229,7 @@ pub struct ListPostReports {
pub unresolved_only: Option<bool>,
/// if no community is given, it returns reports for all communities moderated by the auth user
pub community_id: Option<CommunityId>,
pub post_id: Option<PostId>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]

@ -12,7 +12,7 @@ use diesel::{
use diesel_async::RunQueryDsl;
use lemmy_db_schema::{
aliases,
newtypes::{CommentReportId, CommunityId, PersonId},
newtypes::{CommentId, CommentReportId, CommunityId, PersonId},
schema::{
comment,
comment_aggregates,
@ -95,6 +95,10 @@ fn queries<'a>() -> Queries<
query = query.filter(post::community_id.eq(community_id));
}
if let Some(comment_id) = options.comment_id {
query = query.filter(comment_report::comment_id.eq(comment_id));
}
// If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
if options.unresolved_only {
query = query
@ -186,6 +190,7 @@ impl CommentReportView {
#[derive(Default)]
pub struct CommentReportQuery {
pub community_id: Option<CommunityId>,
pub comment_id: Option<CommentId>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub unresolved_only: bool,

@ -11,7 +11,7 @@ use diesel::{
use diesel_async::RunQueryDsl;
use lemmy_db_schema::{
aliases,
newtypes::{CommunityId, PersonId, PostReportId},
newtypes::{CommunityId, PersonId, PostId, PostReportId},
schema::{
community,
community_moderator,
@ -83,6 +83,10 @@ fn queries<'a>() -> Queries<
query = query.filter(post::community_id.eq(community_id));
}
if let Some(post_id) = options.post_id {
query = query.filter(post::id.eq(post_id));
}
// If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
if options.unresolved_only {
query = query
@ -171,6 +175,7 @@ impl PostReportView {
#[derive(Default)]
pub struct PostReportQuery {
pub community_id: Option<CommunityId>,
pub post_id: Option<PostId>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub unresolved_only: bool,

Loading…
Cancel
Save