diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index 17093dda..574c626c 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -17,8 +17,12 @@ use activitypub::{ object::{Note, Tombstone}, }; use activitystreams::{ - activity::Create as Create07, base::Base, iri_string::types::IriString, object::Note as Note07, - prelude::*, time::OffsetDateTime, + activity::{Create as Create07, Delete as Delete07}, + base::Base, + iri_string::types::IriString, + object::{Note as Note07, Tombstone as Tombstone07}, + prelude::*, + time::OffsetDateTime, }; use chrono::{self, NaiveDateTime, TimeZone, Utc}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; @@ -262,6 +266,26 @@ impl Comment { Ok(act) } + + pub fn build_delete07(&self, conn: &Connection) -> Result { + let mut tombstone = Tombstone07::new(); + tombstone.set_id( + self.ap_url + .as_ref() + .ok_or(Error::MissingApProperty)? + .parse::()?, + ); + + let mut act = Delete07::new( + self.get_author(conn)?.into_id().parse::()?, + Base::retract(tombstone)?.into_generic()?, + ); + + act.set_id(format!("{}#delete", self.ap_url.clone().unwrap()).parse::()?); + act.set_many_tos(vec![PUBLIC_VISIBILITY.parse::()?]); + + Ok(act) + } } impl FromId for Comment {