diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 37de0777..981462dd 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -10,7 +10,7 @@ use activitypub::{ CustomObject, }; use activitystreams::{ - activity::Create as Create07, + activity::{Create as Create07, Update as Update07}, base::{AnyBase, Base}, iri_string::types::IriString, object::{ApObject, Article as Article07, Image as Image07}, @@ -539,6 +539,22 @@ impl Post { Ok(act) } + pub fn update_activity07(&self, conn: &Connection) -> Result { + let article = self.to_activity07(conn)?; + let to = article.to().ok_or(Error::MissingApProperty)?.clone(); + let cc = article.cc().ok_or(Error::MissingApProperty)?.clone(); + let mut act = Update07::new( + self.get_authors(conn)?[0].ap_url.parse::()?, + Base::retract(article)?.into_generic()?, + ); + act.set_id( + format!("{}/update-{}", self.ap_url, Utc::now().timestamp()).parse::()?, + ); + act.set_many_tos(to); + act.set_many_ccs(cc); + Ok(act) + } + pub fn update_mentions(&self, conn: &Connection, mentions: Vec) -> Result<()> { let mentions = mentions .into_iter()