2 activities::{community::get_community_from_moderators_url, verify_community_matches},
4 objects::{community::ApubCommunity, person::ApubPerson},
7 use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many};
8 use activitystreams_kinds::activity::AddType;
9 use lemmy_utils::error::LemmyError;
10 use lemmy_websocket::LemmyContext;
11 use serde::{Deserialize, Serialize};
14 #[derive(Clone, Debug, Deserialize, Serialize)]
15 #[serde(rename_all = "camelCase")]
17 pub(crate) actor: ObjectId<ApubPerson>,
18 #[serde(deserialize_with = "deserialize_one_or_many")]
19 pub(crate) to: Vec<Url>,
20 pub(crate) object: ObjectId<ApubPerson>,
21 pub(crate) target: Url,
22 #[serde(deserialize_with = "deserialize_one_or_many")]
23 pub(crate) cc: Vec<Url>,
24 #[serde(rename = "type")]
25 pub(crate) kind: AddType,
27 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
30 #[async_trait::async_trait(?Send)]
31 impl InCommunity for AddMod {
34 context: &LemmyContext,
35 request_counter: &mut i32,
36 ) -> Result<ApubCommunity, LemmyError> {
38 get_community_from_moderators_url(&self.target, 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, mod_community.id)?;