verify_person_in_community,
},
activity_lists::AnnouncableActivities,
+ check_apub_id_valid,
+ fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::block::block_user::BlockUser,
CommunityPersonBanForm,
},
moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
- person::Person,
+ person::{Person, PersonUpdateForm},
},
traits::{Bannable, Crud, Followable},
};
-use lemmy_utils::{error::LemmyError, settings::structs::Settings, utils::convert_datetime};
+use lemmy_utils::{error::LemmyError, utils::convert_datetime};
use lemmy_websocket::LemmyContext;
use url::Url;
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
+ let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
+ check_apub_id_valid(self.id(), &local_site_data, context.settings())
+ .map_err(LemmyError::from_message)?;
+
verify_is_public(&self.to, &self.cc)?;
match self
.target
{
SiteOrCommunity::Site(site) => {
let domain = self.object.inner().domain().expect("url needs domain");
- if Settings::get().hostname == domain {
+ if context.settings().hostname == domain {
return Err(
anyhow!("Site bans from remote instance can't affect user's home instance").into(),
);
verify_mod_action(
&self.actor,
self.object.inner(),
- &community,
+ community.id,
context,
request_counter,
)
match target {
SiteOrCommunity::Site(_site) => {
let blocked_person = blocking(context.pool(), move |conn| {
- Person::ban_person(conn, blocked_person.id, true, expires)
+ Person::update(
+ conn,
+ blocked_person.id,
+ &PersonUpdateForm::builder()
+ .banned(Some(true))
+ .ban_expires(Some(expires))
+ .build(),
+ )
})
.await??;
if self.remove_data.unwrap_or(false) {
- remove_user_data(blocked_person.id, context.pool()).await?;
+ remove_user_data(
+ blocked_person.id,
+ context.pool(),
+ context.settings(),
+ context.client(),
+ )
+ .await?;
}
// write mod log
person_id: blocked_person.id,
pending: false,
};
- blocking(context.pool(), move |conn: &'_ _| {
+ blocking(context.pool(), move |conn: &mut _| {
CommunityFollower::unfollow(conn, &community_follower_form)
})
.await?