Use Post::build_delete07() instead of build_delete()
This commit is contained in:
parent
a958300a58
commit
2a85f775e9
@ -4,8 +4,7 @@ use crate::{
|
||||
Connection, Error, PostEvent::*, Result, CONFIG, POST_CHAN,
|
||||
};
|
||||
use activitypub::{
|
||||
activity::Delete,
|
||||
object::{Article, Image, Tombstone},
|
||||
object::{Article, Image},
|
||||
CustomObject,
|
||||
};
|
||||
use activitystreams::{
|
||||
@ -653,22 +652,6 @@ impl Post {
|
||||
.and_then(|c| c.url().ok())
|
||||
}
|
||||
|
||||
pub fn build_delete(&self, conn: &Connection) -> Result<Delete> {
|
||||
let mut act = Delete::default();
|
||||
act.delete_props
|
||||
.set_actor_link(self.get_authors(conn)?[0].clone().into_id())?;
|
||||
|
||||
let mut tombstone = Tombstone::default();
|
||||
tombstone.object_props.set_id_string(self.ap_url.clone())?;
|
||||
act.delete_props.set_object_object(tombstone)?;
|
||||
|
||||
act.object_props
|
||||
.set_id_string(format!("{}#delete", self.ap_url))?;
|
||||
act.object_props
|
||||
.set_to_link_vec(vec![Id::new(PUBLIC_VISIBILITY)])?;
|
||||
Ok(act)
|
||||
}
|
||||
|
||||
pub fn build_delete07(&self, conn: &Connection) -> Result<Delete07> {
|
||||
let mut tombstone = Tombstone07::new();
|
||||
tombstone.set_id(self.ap_url.parse()?);
|
||||
@ -1411,32 +1394,6 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_delete() {
|
||||
let conn = db();
|
||||
conn.test_transaction::<_, Error, _>(|| {
|
||||
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
||||
let act = post.build_delete(&conn)?;
|
||||
|
||||
let expected = json!({
|
||||
"actor": "https://plu.me/@/admin/",
|
||||
"id": "https://plu.me/~/BlogName/testing#delete",
|
||||
"object": {
|
||||
"id": "https://plu.me/~/BlogName/testing",
|
||||
"type": "Tombstone"
|
||||
},
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"type": "Delete"
|
||||
});
|
||||
|
||||
assert_json_eq!(to_value(act)?, expected);
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_delete07() {
|
||||
let conn = db();
|
||||
|
@ -16,7 +16,7 @@ use crate::routes::{
|
||||
use crate::template_utils::{IntoContext, Ructe};
|
||||
use crate::utils::requires_login;
|
||||
use plume_common::activity_pub::{
|
||||
broadcast, broadcast07, ActivityStream, ApRequest, LicensedArticle as LicensedArticle07,
|
||||
broadcast07, ActivityStream, ApRequest, LicensedArticle as LicensedArticle07,
|
||||
};
|
||||
use plume_common::utils::md_to_html;
|
||||
use plume_models::{
|
||||
@ -606,7 +606,7 @@ pub fn delete(
|
||||
}
|
||||
|
||||
let dest = User::one_by_instance(&conn)?;
|
||||
let delete_activity = post.build_delete(&conn)?;
|
||||
let delete_activity = post.build_delete07(&conn)?;
|
||||
inbox(
|
||||
&conn,
|
||||
serde_json::to_value(&delete_activity).map_err(Error::from)?,
|
||||
@ -615,7 +615,7 @@ pub fn delete(
|
||||
let user_c = user.clone();
|
||||
rockets
|
||||
.worker
|
||||
.execute(move || broadcast(&user_c, delete_activity, dest, CONFIG.proxy().cloned()));
|
||||
.execute(move || broadcast07(&user_c, delete_activity, dest, CONFIG.proxy().cloned()));
|
||||
rockets
|
||||
.worker
|
||||
.execute_after(Duration::from_secs(10 * 60), move || {
|
||||
|
Loading…
Reference in New Issue
Block a user