2 activities::verify_community_matches,
3 objects::{community::ApubCommunity, person::ApubPerson},
4 protocol::{activities::CreateOrUpdateType, objects::page::Page, InCommunity},
6 use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many};
7 use lemmy_api_common::context::LemmyContext;
8 use lemmy_utils::error::LemmyError;
9 use serde::{Deserialize, Serialize};
12 #[derive(Clone, Debug, Deserialize, Serialize)]
13 #[serde(rename_all = "camelCase")]
14 pub struct CreateOrUpdatePage {
15 pub(crate) actor: ObjectId<ApubPerson>,
16 #[serde(deserialize_with = "deserialize_one_or_many")]
17 pub(crate) to: Vec<Url>,
18 pub(crate) object: Page,
19 #[serde(deserialize_with = "deserialize_one_or_many")]
20 pub(crate) cc: Vec<Url>,
21 #[serde(rename = "type")]
22 pub(crate) kind: CreateOrUpdateType,
24 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
27 #[async_trait::async_trait(?Send)]
28 impl InCommunity for CreateOrUpdatePage {
31 context: &LemmyContext,
32 request_counter: &mut i32,
33 ) -> Result<ApubCommunity, LemmyError> {
34 let community = self.object.community(context, request_counter).await?;
35 if let Some(audience) = &self.audience {
36 verify_community_matches(audience, community.actor_id.clone())?;