2 activities::verify_community_matches,
3 fetcher::post_or_comment::PostOrComment,
4 objects::{community::ApubCommunity, person::ApubPerson},
7 use activitypub_federation::{
9 fetch::object_id::ObjectId,
10 kinds::activity::FlagType,
11 protocol::helpers::deserialize_one,
13 use lemmy_api_common::context::LemmyContext;
14 use lemmy_utils::error::LemmyError;
15 use serde::{Deserialize, Serialize};
18 #[derive(Clone, Debug, Deserialize, Serialize)]
19 #[serde(rename_all = "camelCase")]
21 pub(crate) actor: ObjectId<ApubPerson>,
22 #[serde(deserialize_with = "deserialize_one")]
23 pub(crate) to: [ObjectId<ApubCommunity>; 1],
24 pub(crate) object: ObjectId<PostOrComment>,
25 pub(crate) summary: String,
26 #[serde(rename = "type")]
27 pub(crate) kind: FlagType,
29 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
32 #[async_trait::async_trait]
33 impl InCommunity for Report {
34 async fn community(&self, context: &Data<LemmyContext>) -> Result<ApubCommunity, LemmyError> {
35 let community = self.to[0].dereference(context).await?;
36 if let Some(audience) = &self.audience {
37 verify_community_matches(audience, community.actor_id.clone())?;