fix: omg it wants embedded undos fix nuke for real

This commit is contained in:
əlemi 2024-06-24 02:43:15 +02:00
parent 206bc4d0db
commit 19a6ca2fcb
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -45,20 +45,20 @@ pub async fn nuke(ctx: upub::Context, for_real: bool, delete_posts: bool) -> Res
continue; continue;
}; };
let Some(oid) = activity.object let Some(ref oid) = activity.object
else { else {
tracing::error!("can't undo activity without object"); tracing::error!("can't undo activity without object");
continue; continue;
}; };
let (target, undone) = if matches!(activity.activity_type, apb::ActivityType::Follow) { let (target, undone) = if matches!(activity.activity_type, apb::ActivityType::Follow) {
(oid.clone(), activity.id.clone()) (oid.clone(), activity.clone().ap())
} else { } else {
let follow_activity = upub::model::activity::Entity::find_by_ap_id(&oid) let follow_activity = upub::model::activity::Entity::find_by_ap_id(oid)
.one(ctx.db()) .one(ctx.db())
.await? .await?
.ok_or(sea_orm::DbErr::RecordNotFound(oid.clone()))?; .ok_or(sea_orm::DbErr::RecordNotFound(oid.clone()))?;
(follow_activity.object.unwrap_or_default(), follow_activity.id) (follow_activity.clone().object.unwrap_or_default(), follow_activity.ap())
}; };
let aid = ctx.aid(&upub::Context::new_id()); let aid = ctx.aid(&upub::Context::new_id());
@ -66,7 +66,7 @@ pub async fn nuke(ctx: upub::Context, for_real: bool, delete_posts: bool) -> Res
.set_id(Some(&aid)) .set_id(Some(&aid))
.set_activity_type(Some(apb::ActivityType::Undo)) .set_activity_type(Some(apb::ActivityType::Undo))
.set_actor(apb::Node::link(activity.actor.clone())) .set_actor(apb::Node::link(activity.actor.clone()))
.set_object(apb::Node::link(undone)) .set_object(apb::Node::object(undone))
.set_to(apb::Node::links(vec![target])) .set_to(apb::Node::links(vec![target]))
.set_published(Some(chrono::Utc::now())); .set_published(Some(chrono::Utc::now()));