Make delete activities backwards compatible with 0.15 (#2114)

This commit is contained in:
Nutomic 2022-03-03 19:37:12 +00:00 committed by GitHub
parent ef1e164cc5
commit df757f28b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -6,7 +6,7 @@ use crate::{
verify_activity, verify_activity,
}, },
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::deletion::delete::{Delete, IdOrNestedObject}, protocol::activities::deletion::delete::{Delete, IdOrNestedObject, NestedObject},
}; };
use activitystreams_kinds::activity::DeleteType; use activitystreams_kinds::activity::DeleteType;
use anyhow::anyhow; use anyhow::anyhow;
@ -104,7 +104,10 @@ impl Delete {
Ok(Delete { Ok(Delete {
actor: ObjectId::new(actor.actor_id.clone()), actor: ObjectId::new(actor.actor_id.clone()),
to: vec![to], to: vec![to],
object: IdOrNestedObject::Id(object.id()), object: IdOrNestedObject::NestedObject(NestedObject {
id: object.id(),
kind: Default::default(),
}),
cc: cc.into_iter().collect(), cc: cc.into_iter().collect(),
kind: DeleteType::Delete, kind: DeleteType::Delete,
summary, summary,

View file

@ -1,5 +1,5 @@
use crate::{objects::person::ApubPerson, protocol::Unparsed}; 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 lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none; use serde_with::skip_serializing_none;
@ -39,7 +39,10 @@ pub(crate) enum IdOrNestedObject {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub(crate) struct NestedObject { 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 { impl IdOrNestedObject {