2 activities::verify_community_matches,
3 fetcher::post_or_comment::PostOrComment,
5 objects::{community::ApubCommunity, person::ApubPerson},
8 use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one};
9 use activitystreams_kinds::activity::FlagType;
10 use lemmy_utils::error::LemmyError;
11 use lemmy_websocket::LemmyContext;
12 use serde::{Deserialize, Serialize};
15 #[derive(Clone, Debug, Deserialize, Serialize)]
16 #[serde(rename_all = "camelCase")]
18 pub(crate) actor: ObjectId<ApubPerson>,
19 #[serde(deserialize_with = "deserialize_one")]
20 pub(crate) to: [ObjectId<ApubCommunity>; 1],
21 pub(crate) object: ObjectId<PostOrComment>,
22 pub(crate) summary: String,
23 #[serde(rename = "type")]
24 pub(crate) kind: FlagType,
26 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
29 #[async_trait::async_trait(?Send)]
30 impl InCommunity for Report {
33 context: &LemmyContext,
34 request_counter: &mut i32,
35 ) -> Result<ApubCommunity, LemmyError> {
36 let to_community = self.to[0]
37 .dereference(context, local_instance(context).await, request_counter)
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, to_community.id)?;