mirror of https://github.com/LemmyNet/lemmy.git
Addressing PR comments.
parent
3ec4478193
commit
380f227204
|
@ -44,7 +44,6 @@ 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)?;
|
check_post_deleted_or_removed(&post_view.post)?;
|
||||||
|
|
||||||
let report_form = PostReportForm {
|
let report_form = PostReportForm {
|
||||||
|
|
|
@ -225,6 +225,7 @@ pub async fn check_community_mod_action(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Don't allow creating reports for removed / deleted posts
|
||||||
pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
||||||
if post.deleted || post.removed {
|
if post.deleted || post.removed {
|
||||||
Err(LemmyErrorType::Deleted)?
|
Err(LemmyErrorType::Deleted)?
|
||||||
|
|
|
@ -14,7 +14,7 @@ use activitypub_federation::{
|
||||||
kinds::activity::FlagType,
|
kinds::activity::FlagType,
|
||||||
traits::{ActivityHandler, Actor},
|
traits::{ActivityHandler, Actor},
|
||||||
};
|
};
|
||||||
use lemmy_api_common::context::LemmyContext;
|
use lemmy_api_common::{context::LemmyContext, utils::check_post_deleted_or_removed};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
|
@ -104,6 +104,8 @@ impl ActivityHandler for Report {
|
||||||
let reason = self.reason()?;
|
let reason = self.reason()?;
|
||||||
match self.object.dereference(context).await? {
|
match self.object.dereference(context).await? {
|
||||||
PostOrComment::Post(post) => {
|
PostOrComment::Post(post) => {
|
||||||
|
check_post_deleted_or_removed(&post)?;
|
||||||
|
|
||||||
let report_form = PostReportForm {
|
let report_form = PostReportForm {
|
||||||
creator_id: actor.id,
|
creator_id: actor.id,
|
||||||
post_id: post.id,
|
post_id: post.id,
|
||||||
|
|
Loading…
Reference in New Issue