mirror of https://github.com/LemmyNet/lemmy.git
Dont allow creating reports for deleted / removed items.
parent
e3511e3e26
commit
946a21752f
|
@ -5,7 +5,11 @@ use lemmy_api_common::{
|
||||||
comment::{CommentReportResponse, CreateCommentReport},
|
comment::{CommentReportResponse, CreateCommentReport},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{check_community_user_action, send_new_report_email_to_admins},
|
utils::{
|
||||||
|
check_comment_deleted_or_removed,
|
||||||
|
check_community_user_action,
|
||||||
|
send_new_report_email_to_admins,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -40,6 +44,9 @@ pub async fn create_comment_report(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// Don't allow creating reports for removed / deleted comments
|
||||||
|
check_comment_deleted_or_removed(&comment_view.comment)?;
|
||||||
|
|
||||||
let report_form = CommentReportForm {
|
let report_form = CommentReportForm {
|
||||||
creator_id: person_id,
|
creator_id: person_id,
|
||||||
comment_id,
|
comment_id,
|
||||||
|
|
|
@ -5,7 +5,11 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
post::{CreatePostReport, PostReportResponse},
|
post::{CreatePostReport, PostReportResponse},
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{check_community_user_action, send_new_report_email_to_admins},
|
utils::{
|
||||||
|
check_community_user_action,
|
||||||
|
check_post_deleted_or_removed,
|
||||||
|
send_new_report_email_to_admins,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -40,6 +44,9 @@ pub async fn create_post_report(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// Don't allow creating reports for removed / deleted posts
|
||||||
|
check_post_deleted_or_removed(&post_view.post)?;
|
||||||
|
|
||||||
let report_form = PostReportForm {
|
let report_form = PostReportForm {
|
||||||
creator_id: person_id,
|
creator_id: person_id,
|
||||||
post_id,
|
post_id,
|
||||||
|
|
|
@ -233,6 +233,14 @@ pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn check_comment_deleted_or_removed(comment: &Comment) -> Result<(), LemmyError> {
|
||||||
|
if comment.deleted || comment.removed {
|
||||||
|
Err(LemmyErrorType::Deleted)?
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Throws an error if a recipient has blocked a person.
|
/// Throws an error if a recipient has blocked a person.
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
pub async fn check_person_block(
|
pub async fn check_person_block(
|
||||||
|
|
Loading…
Reference in New Issue