2 activities::verify_community_matches,
3 objects::{community::ApubCommunity, person::ApubPerson},
4 protocol::{activities::deletion::delete::Delete, InCommunity},
6 use activitypub_federation::{
8 fetch::object_id::ObjectId,
9 kinds::activity::UndoType,
10 protocol::helpers::deserialize_one_or_many,
12 use lemmy_api_common::context::LemmyContext;
13 use lemmy_utils::error::LemmyError;
14 use serde::{Deserialize, Serialize};
15 use serde_with::skip_serializing_none;
18 #[skip_serializing_none]
19 #[derive(Clone, Debug, Deserialize, Serialize)]
20 #[serde(rename_all = "camelCase")]
21 pub struct UndoDelete {
22 pub(crate) actor: ObjectId<ApubPerson>,
23 #[serde(deserialize_with = "deserialize_one_or_many")]
24 pub(crate) to: Vec<Url>,
25 pub(crate) object: Delete,
26 #[serde(rename = "type")]
27 pub(crate) kind: UndoType,
29 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
31 #[serde(deserialize_with = "deserialize_one_or_many", default)]
32 #[serde(skip_serializing_if = "Vec::is_empty")]
33 pub(crate) cc: Vec<Url>,
36 #[async_trait::async_trait]
37 impl InCommunity for UndoDelete {
38 async fn community(&self, context: &Data<LemmyContext>) -> Result<ApubCommunity, LemmyError> {
39 let community = self.object.community(context).await?;
40 if let Some(audience) = &self.audience {
41 verify_community_matches(audience, community.actor_id.clone())?;