mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 03:11:08 +00:00
parent
36ad1868b3
commit
52155c74cb
6 changed files with 18 additions and 2 deletions
|
@ -16,6 +16,7 @@ pub async fn list_comment_reports(
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
) -> Result<Json<ListCommentReportsResponse>, LemmyError> {
|
) -> Result<Json<ListCommentReportsResponse>, LemmyError> {
|
||||||
let community_id = data.community_id;
|
let community_id = data.community_id;
|
||||||
|
let comment_id = data.comment_id;
|
||||||
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
||||||
|
|
||||||
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
|
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 limit = data.limit;
|
||||||
let comment_reports = CommentReportQuery {
|
let comment_reports = CommentReportQuery {
|
||||||
community_id,
|
community_id,
|
||||||
|
comment_id,
|
||||||
unresolved_only,
|
unresolved_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub async fn list_post_reports(
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
) -> Result<Json<ListPostReportsResponse>, LemmyError> {
|
) -> Result<Json<ListPostReportsResponse>, LemmyError> {
|
||||||
let community_id = data.community_id;
|
let community_id = data.community_id;
|
||||||
|
let post_id = data.post_id;
|
||||||
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
||||||
|
|
||||||
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
|
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 limit = data.limit;
|
||||||
let post_reports = PostReportQuery {
|
let post_reports = PostReportQuery {
|
||||||
community_id,
|
community_id,
|
||||||
|
post_id,
|
||||||
unresolved_only,
|
unresolved_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
|
|
|
@ -161,6 +161,7 @@ pub struct ResolveCommentReport {
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
/// List comment reports.
|
/// List comment reports.
|
||||||
pub struct ListCommentReports {
|
pub struct ListCommentReports {
|
||||||
|
pub comment_id: Option<CommentId>,
|
||||||
pub page: Option<i64>,
|
pub page: Option<i64>,
|
||||||
pub limit: Option<i64>,
|
pub limit: Option<i64>,
|
||||||
/// Only shows the unresolved reports
|
/// Only shows the unresolved reports
|
||||||
|
|
|
@ -229,6 +229,7 @@ pub struct ListPostReports {
|
||||||
pub unresolved_only: Option<bool>,
|
pub unresolved_only: Option<bool>,
|
||||||
/// if no community is given, it returns reports for all communities moderated by the auth user
|
/// if no community is given, it returns reports for all communities moderated by the auth user
|
||||||
pub community_id: Option<CommunityId>,
|
pub community_id: Option<CommunityId>,
|
||||||
|
pub post_id: Option<PostId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
|
|
@ -12,7 +12,7 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
aliases,
|
aliases,
|
||||||
newtypes::{CommentReportId, CommunityId, PersonId},
|
newtypes::{CommentId, CommentReportId, CommunityId, PersonId},
|
||||||
schema::{
|
schema::{
|
||||||
comment,
|
comment,
|
||||||
comment_aggregates,
|
comment_aggregates,
|
||||||
|
@ -95,6 +95,10 @@ fn queries<'a>() -> Queries<
|
||||||
query = query.filter(post::community_id.eq(community_id));
|
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 viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
|
||||||
if options.unresolved_only {
|
if options.unresolved_only {
|
||||||
query = query
|
query = query
|
||||||
|
@ -186,6 +190,7 @@ impl CommentReportView {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct CommentReportQuery {
|
pub struct CommentReportQuery {
|
||||||
pub community_id: Option<CommunityId>,
|
pub community_id: Option<CommunityId>,
|
||||||
|
pub comment_id: Option<CommentId>,
|
||||||
pub page: Option<i64>,
|
pub page: Option<i64>,
|
||||||
pub limit: Option<i64>,
|
pub limit: Option<i64>,
|
||||||
pub unresolved_only: bool,
|
pub unresolved_only: bool,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
aliases,
|
aliases,
|
||||||
newtypes::{CommunityId, PersonId, PostReportId},
|
newtypes::{CommunityId, PersonId, PostId, PostReportId},
|
||||||
schema::{
|
schema::{
|
||||||
community,
|
community,
|
||||||
community_moderator,
|
community_moderator,
|
||||||
|
@ -83,6 +83,10 @@ fn queries<'a>() -> Queries<
|
||||||
query = query.filter(post::community_id.eq(community_id));
|
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 viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
|
||||||
if options.unresolved_only {
|
if options.unresolved_only {
|
||||||
query = query
|
query = query
|
||||||
|
@ -171,6 +175,7 @@ impl PostReportView {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PostReportQuery {
|
pub struct PostReportQuery {
|
||||||
pub community_id: Option<CommunityId>,
|
pub community_id: Option<CommunityId>,
|
||||||
|
pub post_id: Option<PostId>,
|
||||||
pub page: Option<i64>,
|
pub page: Option<i64>,
|
||||||
pub limit: Option<i64>,
|
pub limit: Option<i64>,
|
||||||
pub unresolved_only: bool,
|
pub unresolved_only: bool,
|
||||||
|
|
Loading…
Reference in a new issue