2 activities::verify_community_matches,
4 objects::{community::ApubCommunity, person::ApubPerson},
5 protocol::{activities::block::block_user::BlockUser, InCommunity},
7 use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many};
8 use activitystreams_kinds::activity::UndoType;
9 use lemmy_api_common::LemmyContext;
10 use lemmy_utils::error::LemmyError;
11 use serde::{Deserialize, Serialize};
12 use serde_with::skip_serializing_none;
15 #[skip_serializing_none]
16 #[derive(Clone, Debug, Deserialize, Serialize)]
17 #[serde(rename_all = "camelCase")]
18 pub struct UndoBlockUser {
19 pub(crate) actor: ObjectId<ApubPerson>,
20 #[serde(deserialize_with = "deserialize_one_or_many")]
21 pub(crate) to: Vec<Url>,
22 pub(crate) object: BlockUser,
23 #[serde(deserialize_with = "deserialize_one_or_many")]
24 pub(crate) cc: Vec<Url>,
25 #[serde(rename = "type")]
26 pub(crate) kind: UndoType,
28 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
31 #[async_trait::async_trait(?Send)]
32 impl InCommunity for UndoBlockUser {
35 context: &LemmyContext,
36 request_counter: &mut i32,
37 ) -> Result<ApubCommunity, LemmyError> {
38 let object_community = self.object.community(context, request_counter).await?;
39 if let Some(audience) = &self.audience {
40 let audience = audience
41 .dereference(context, local_instance(context).await, request_counter)
43 verify_community_matches(&audience, object_community.id)?;