},
traits::Crud,
};
-use lemmy_utils::error::LemmyError;
+use lemmy_utils::error::{LemmyError, LemmyErrorType};
use url::Url;
#[async_trait::async_trait]
match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => {
if community.local {
- return Err(LemmyError::from_message(
- "Only local admin can remove community",
- ));
+ return Err(LemmyErrorType::OnlyLocalAdminCanRemoveCommunity)?;
}
let form = ModRemoveCommunityForm {
mod_person_id: actor.id,
reason,
expires: None,
};
- ModRemoveCommunity::create(context.pool(), &form).await?;
+ ModRemoveCommunity::create(&mut context.pool(), &form).await?;
Community::update(
- context.pool(),
+ &mut context.pool(),
community.id,
&CommunityUpdateForm::builder().removed(Some(true)).build(),
)
removed: Some(true),
reason,
};
- ModRemovePost::create(context.pool(), &form).await?;
+ ModRemovePost::create(&mut context.pool(), &form).await?;
Post::update(
- context.pool(),
+ &mut context.pool(),
post.id,
&PostUpdateForm::builder().removed(Some(true)).build(),
)
removed: Some(true),
reason,
};
- ModRemoveComment::create(context.pool(), &form).await?;
+ ModRemoveComment::create(&mut context.pool(), &form).await?;
Comment::update(
- context.pool(),
+ &mut context.pool(),
comment.id,
&CommentUpdateForm::builder().removed(Some(true)).build(),
)