From df757f28b4c4e4b5b8b32db992bdc74f6baebabf Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 3 Mar 2022 19:37:12 +0000 Subject: [PATCH] Make delete activities backwards compatible with 0.15 (#2114) --- crates/apub/src/activities/deletion/delete.rs | 7 +++++-- crates/apub/src/protocol/activities/deletion/delete.rs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index e141fcadd..3bb4b5bc8 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -6,7 +6,7 @@ use crate::{ verify_activity, }, objects::{community::ApubCommunity, person::ApubPerson}, - protocol::activities::deletion::delete::{Delete, IdOrNestedObject}, + protocol::activities::deletion::delete::{Delete, IdOrNestedObject, NestedObject}, }; use activitystreams_kinds::activity::DeleteType; use anyhow::anyhow; @@ -104,7 +104,10 @@ impl Delete { Ok(Delete { actor: ObjectId::new(actor.actor_id.clone()), to: vec![to], - object: IdOrNestedObject::Id(object.id()), + object: IdOrNestedObject::NestedObject(NestedObject { + id: object.id(), + kind: Default::default(), + }), cc: cc.into_iter().collect(), kind: DeleteType::Delete, summary, diff --git a/crates/apub/src/protocol/activities/deletion/delete.rs b/crates/apub/src/protocol/activities/deletion/delete.rs index 6913652fa..d3ec53be5 100644 --- a/crates/apub/src/protocol/activities/deletion/delete.rs +++ b/crates/apub/src/protocol/activities/deletion/delete.rs @@ -1,5 +1,5 @@ use crate::{objects::person::ApubPerson, protocol::Unparsed}; -use activitystreams_kinds::activity::DeleteType; +use activitystreams_kinds::{activity::DeleteType, object::TombstoneType}; use lemmy_apub_lib::object_id::ObjectId; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; @@ -39,7 +39,10 @@ pub(crate) enum IdOrNestedObject { #[derive(Clone, Debug, Deserialize, Serialize)] pub(crate) struct NestedObject { - id: Url, + pub(crate) id: Url, + // Backwards compatibility with Lemmy 0.15 + #[serde(rename = "type")] + pub(crate) kind: TombstoneType, } impl IdOrNestedObject {