mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Dont allow blocking admin (#2340)
This commit is contained in:
parent
ddc9763050
commit
3ef812660c
1 changed files with 10 additions and 6 deletions
|
@ -39,6 +39,15 @@ impl Perform for BlockPerson {
|
|||
target_id,
|
||||
};
|
||||
|
||||
let target_person_view = blocking(context.pool(), move |conn| {
|
||||
PersonViewSafe::read(conn, target_id)
|
||||
})
|
||||
.await??;
|
||||
|
||||
if target_person_view.person.admin {
|
||||
return Err(LemmyError::from_message("cant_block_admin"));
|
||||
}
|
||||
|
||||
if data.block {
|
||||
let block = move |conn: &'_ _| PersonBlock::block(conn, &person_block_form);
|
||||
blocking(context.pool(), block)
|
||||
|
@ -51,13 +60,8 @@ impl Perform for BlockPerson {
|
|||
.map_err(|e| LemmyError::from_error_message(e, "person_block_already_exists"))?;
|
||||
}
|
||||
|
||||
let person_view = blocking(context.pool(), move |conn| {
|
||||
PersonViewSafe::read(conn, target_id)
|
||||
})
|
||||
.await??;
|
||||
|
||||
let res = BlockPersonResponse {
|
||||
person_view,
|
||||
person_view: target_person_view,
|
||||
blocked: data.block,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue