Dont allow blocking local instance (fixes #4241) (#4242)

* Dont allow blocking local instance (fixes #4241)

* use localuserview
This commit is contained in:
Nutomic 2023-12-11 20:35:53 +01:00 committed by GitHub
parent cef3f220a2
commit e317947b75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -19,6 +19,10 @@ pub async fn block_instance(
) -> Result<Json<BlockInstanceResponse>, LemmyError> { ) -> Result<Json<BlockInstanceResponse>, LemmyError> {
let instance_id = data.instance_id; let instance_id = data.instance_id;
let person_id = local_user_view.person.id; let person_id = local_user_view.person.id;
if local_user_view.person.instance_id == instance_id {
return Err(LemmyErrorType::CantBlockLocalInstance)?;
}
let instance_block_form = InstanceBlockForm { let instance_block_form = InstanceBlockForm {
person_id, person_id,
instance_id, instance_id,

View file

@ -227,6 +227,7 @@ pub enum LemmyErrorType {
BanExpirationInPast, BanExpirationInPast,
InvalidUnixTime, InvalidUnixTime,
InvalidBotAction, InvalidBotAction,
CantBlockLocalInstance,
Unknown(String), Unknown(String),
} }