1 use crate::{objects::person::ApubPerson, protocol::Unparsed};
2 use activitystreams_kinds::activity::DeleteType;
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(deserialize_with = "crate::deserialize_one_or_many")]
18 #[serde(skip_serializing_if = "Vec::is_empty")]
19 pub(crate) cc: Vec<Url>,
20 #[serde(rename = "type")]
21 pub(crate) kind: DeleteType,
22 /// If summary is present, this is a mod action (Remove in Lemmy terms). Otherwise, its a user
23 /// deleting their own content.
24 pub(crate) summary: Option<String>,
27 pub(crate) unparsed: Unparsed,
30 /// Instead of a simple ID string as object, Mastodon sends a nested tombstone for some reason,
31 /// so we need to handle that as well.
32 #[derive(Clone, Debug, Deserialize, Serialize)]
34 pub(crate) enum IdOrNestedObject {
36 NestedObject(NestedObject),
39 #[derive(Clone, Debug, Deserialize, Serialize)]
40 pub(crate) struct NestedObject {
44 impl IdOrNestedObject {
45 pub(crate) fn id(&self) -> &Url {
47 IdOrNestedObject::Id(i) => i,
48 IdOrNestedObject::NestedObject(n) => &n.id,