Mods and admins can comment in locked posts (fixes #4116)

mods-comment-locked
Felix Ableitner 3 months ago
parent 328a48c9f5
commit 4d729e40d9

@ -15,6 +15,7 @@ use lemmy_api_common::{
EndpointType,
},
};
use lemmy_api_common::utils::is_mod_or_admin;
use lemmy_db_schema::{
impls::actor_language::default_post_language,
source::{
@ -55,7 +56,8 @@ pub async fn create_comment(
check_post_deleted_or_removed(&post)?;
// Check if post is locked, no new comments
if post.locked {
let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), local_user_view.person, community_id)?;
if post.locked && !is_mod_or_admin {
Err(LemmyErrorType::Locked)?
}

@ -36,6 +36,7 @@ use lemmy_utils::{
};
use std::ops::Deref;
use url::Url;
use lemmy_api_common::utils::is_mod_or_admin;
#[derive(Clone, Debug)]
pub struct ApubComment(pub(crate) Comment);
@ -142,7 +143,9 @@ impl Object for ApubComment {
verify_is_remote_object(note.id.inner(), context.settings())?;
verify_person_in_community(&note.attributed_to, &community, context).await?;
let (post, _) = note.get_parents(context).await?;
if post.locked {
let creator = note.attributed_to.dereference(context).await?;
let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), creator, community.id)?;
if post.locked && !is_mod_or_admin {
Err(LemmyErrorType::PostIsLocked)?
} else {
Ok(())

Loading…
Cancel
Save