},
activity_queue::send_to_community_new,
extensions::context::lemmy_context,
- fetcher::{community::get_or_fetch_and_upsert_community, person::get_or_fetch_and_upsert_person},
+ fetcher::object_id::ObjectId,
ActorType,
};
use activitystreams::{
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
#[serde(rename_all = "camelCase")]
pub struct BlockUserFromCommunity {
- actor: Url,
- to: PublicUrl,
- pub(in crate::activities::community) object: Url,
- cc: [Url; 1],
+ actor: ObjectId<Person>,
+ to: [PublicUrl; 1],
+ pub(in crate::activities::community) object: ObjectId<Person>,
+ cc: [ObjectId<Community>; 1],
#[serde(rename = "type")]
kind: BlockType,
id: Url,
actor: &Person,
) -> Result<BlockUserFromCommunity, LemmyError> {
Ok(BlockUserFromCommunity {
- actor: actor.actor_id(),
- to: PublicUrl::Public,
- object: target.actor_id(),
- cc: [community.actor_id()],
+ actor: ObjectId::new(actor.actor_id()),
+ to: [PublicUrl::Public],
+ object: ObjectId::new(target.actor_id()),
+ cc: [ObjectId::new(community.actor_id())],
kind: BlockType::Block,
id: generate_activity_id(BlockType::Block)?,
context: lemmy_context(),
context: &LemmyContext,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let community =
- get_or_fetch_and_upsert_community(&self.cc[0], context, request_counter).await?;
- let blocked_user =
- get_or_fetch_and_upsert_person(&self.object, context, request_counter).await?;
+ let community = self.cc[0].dereference(context, request_counter).await?;
+ let blocked_user = self.object.dereference(context, request_counter).await?;
let community_user_ban_form = CommunityPersonBanForm {
community_id: community.id,