Implement Post::update_activity07()

This commit is contained in:
Kitaiti Makoto 2022-03-21 09:42:00 +09:00
parent 871618f45d
commit 16e012ba00

View file

@ -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<Update07> {
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::<IriString>()?,
Base::retract(article)?.into_generic()?,
);
act.set_id(
format!("{}/update-{}", self.ap_url, Utc::now().timestamp()).parse::<IriString>()?,
);
act.set_many_tos(to);
act.set_many_ccs(cc);
Ok(act)
}
pub fn update_mentions(&self, conn: &Connection, mentions: Vec<link::Mention>) -> Result<()> {
let mentions = mentions
.into_iter()