2 activities::verify_community_matches,
4 objects::{community::ApubCommunity, person::ApubPerson},
5 protocol::{activities::deletion::delete::Delete, InCommunity},
7 use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many};
8 use activitystreams_kinds::activity::UndoType;
9 use lemmy_utils::error::LemmyError;
10 use lemmy_websocket::LemmyContext;
11 use serde::{Deserialize, Serialize};
12 use serde_with::skip_serializing_none;
15 #[skip_serializing_none]
16 #[derive(Clone, Debug, Deserialize, Serialize)]
17 #[serde(rename_all = "camelCase")]
18 pub struct UndoDelete {
19 pub(crate) actor: ObjectId<ApubPerson>,
20 #[serde(deserialize_with = "deserialize_one_or_many")]
21 pub(crate) to: Vec<Url>,
22 pub(crate) object: Delete,
23 #[serde(rename = "type")]
24 pub(crate) kind: UndoType,
26 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
28 #[serde(deserialize_with = "deserialize_one_or_many", default)]
29 #[serde(skip_serializing_if = "Vec::is_empty")]
30 pub(crate) cc: Vec<Url>,
33 #[async_trait::async_trait(?Send)]
34 impl InCommunity for UndoDelete {
37 context: &LemmyContext,
38 request_counter: &mut i32,
39 ) -> Result<ApubCommunity, LemmyError> {
40 let object_community = self.object.community(context, request_counter).await?;
41 if let Some(audience) = &self.audience {
42 let audience = audience
43 .dereference(context, local_instance(context).await, request_counter)
45 verify_community_matches(&audience, object_community.id)?;