};
use lemmy_db_views_actor::structs::PersonView;
use lemmy_utils::{
- error::LemmyError,
+ error::{LemmyError, LemmyErrorExt, LemmyErrorType},
utils::{time::naive_from_unix, validation::is_valid_body_field},
};
let expires = data.expires.map(naive_from_unix);
let person = Person::update(
- context.pool(),
+ &mut context.pool(),
banned_person_id,
&PersonUpdateForm::builder()
.banned(Some(ban))
.build(),
)
.await
- .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_user"))?;
+ .with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?;
// Remove their data if that's desired
let remove_data = data.remove_data.unwrap_or(false);
if remove_data {
remove_user_data(
person.id,
- context.pool(),
+ &mut context.pool(),
context.settings(),
context.client(),
)
expires,
};
- ModBan::create(context.pool(), &form).await?;
+ ModBan::create(&mut context.pool(), &form).await?;
let person_id = data.person_id;
- let person_view = PersonView::read(context.pool(), person_id).await?;
+ let person_view = PersonView::read(&mut context.pool(), person_id).await?;
Ok(BanPersonResponse {
person_view,