Implement Mention::build_delete07()

This commit is contained in:
Kitaiti Makoto 2022-03-21 10:32:12 +09:00
parent 98e0754976
commit 3e9d9a81b7

View File

@ -10,11 +10,11 @@ use activitypub::{
CustomObject, CustomObject,
}; };
use activitystreams::{ use activitystreams::{
activity::{Create as Create07, Update as Update07}, activity::{Create as Create07, Delete as Delete07, Update as Update07},
base::{AnyBase, Base}, base::{AnyBase, Base},
iri_string::types::IriString, iri_string::types::IriString,
link as link07, link as link07,
object::{ApObject, Article as Article07, Image as Image07}, object::{ApObject, Article as Article07, Image as Image07, Tombstone as Tombstone07},
prelude::*, prelude::*,
time::OffsetDateTime, time::OffsetDateTime,
}; };
@ -811,6 +811,23 @@ impl Post {
Ok(act) Ok(act)
} }
pub fn build_delete07(&self, conn: &Connection) -> Result<Delete07> {
let mut tombstone = Tombstone07::new();
tombstone.set_id(self.ap_url.parse()?);
let mut act = Delete07::new(
self.get_authors(conn)?[0]
.clone()
.into_id()
.parse::<IriString>()?,
Base::retract(tombstone)?.into_generic()?,
);
act.set_id(format!("{}#delete", self.ap_url).parse()?);
act.set_many_tos(vec![PUBLIC_VISIBILITY.parse::<IriString>()?]);
Ok(act)
}
fn publish_published(&self) { fn publish_published(&self) {
POST_CHAN.tell( POST_CHAN.tell(
Publish { Publish {