1 use crate::{objects::person::ApubPerson, protocol::Unparsed};
2 use activitystreams_kinds::{activity::DeleteType, object::TombstoneType};
3 use lemmy_apub_lib::object_id::ObjectId;
4 use serde::{Deserialize, Serialize};
5 use serde_with::skip_serializing_none;
8 #[skip_serializing_none]
9 #[derive(Clone, Debug, Deserialize, Serialize)]
10 #[serde(rename_all = "camelCase")]
12 pub(crate) actor: ObjectId<ApubPerson>,
13 #[serde(deserialize_with = "crate::deserialize_one_or_many")]
14 pub(crate) to: Vec<Url>,
15 pub(crate) object: IdOrNestedObject,
16 #[serde(rename = "type")]
17 pub(crate) kind: DeleteType,
20 #[serde(deserialize_with = "crate::deserialize_one_or_many")]
22 #[serde(skip_serializing_if = "Vec::is_empty")]
23 pub(crate) cc: Vec<Url>,
24 /// If summary is present, this is a mod action (Remove in Lemmy terms). Otherwise, its a user
25 /// deleting their own content.
26 pub(crate) summary: Option<String>,
28 pub(crate) unparsed: Unparsed,
31 /// Instead of a simple ID string as object, Mastodon sends a nested tombstone for some reason,
32 /// so we need to handle that as well.
33 #[derive(Clone, Debug, Deserialize, Serialize)]
35 pub(crate) enum IdOrNestedObject {
37 NestedObject(NestedObject),
40 #[derive(Clone, Debug, Deserialize, Serialize)]
41 pub(crate) struct NestedObject {
43 // Backwards compatibility with Lemmy 0.15
44 #[serde(rename = "type")]
45 pub(crate) kind: TombstoneType,
48 impl IdOrNestedObject {
49 pub(crate) fn id(&self) -> &Url {
51 IdOrNestedObject::Id(i) => i,
52 IdOrNestedObject::NestedObject(n) => &n.id,