From bbf696fe6ee8f659ba2e4a0f22fcd19d532a5e55 Mon Sep 17 00:00:00 2001 From: silverpill Date: Fri, 19 Nov 2021 00:05:39 +0000 Subject: [PATCH] Handle Delete activities that don't have object type --- README.md | 2 +- src/activitypub/receiver.rs | 14 ++++++++++---- src/activitypub/vocabulary.rs | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f94b3e4..1c9250b 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The following activities are supported: - Accept(Follow) - Reject(Follow) - Create(Note) -- Delete(Tombstone) +- Delete(Note) - Like(Note) - Follow(Person) - Undo(Follow) diff --git a/src/activitypub/receiver.rs b/src/activitypub/receiver.rs index 7797bf8..124b013 100644 --- a/src/activitypub/receiver.rs +++ b/src/activitypub/receiver.rs @@ -292,10 +292,16 @@ pub async fn receive_activity( .map_err(|_| ValidationError("invalid object"))?; process_note(config, db_client, object).await?; }, - (DELETE, TOMBSTONE) => { - let object: Object = serde_json::from_value(activity.object) - .map_err(|_| ValidationError("invalid object"))?; - let post = get_post_by_object_id(db_client, &object.id).await?; + (DELETE, _) => { + let object_id = match activity.object.as_str() { + Some(object_id) => object_id.to_owned(), + None => { + let object: Object = serde_json::from_value(activity.object) + .map_err(|_| ValidationError("invalid object"))?; + object.id + }, + }; + let post = get_post_by_object_id(db_client, &object_id).await?; let deletion_queue = delete_post(db_client, &post.id).await?; let config = config.clone(); actix_rt::spawn(async move { diff --git a/src/activitypub/vocabulary.rs b/src/activitypub/vocabulary.rs index 3c9993a..637d5af 100644 --- a/src/activitypub/vocabulary.rs +++ b/src/activitypub/vocabulary.rs @@ -19,7 +19,6 @@ pub const DOCUMENT: &str = "Document"; pub const IMAGE: &str = "Image"; pub const MENTION: &str = "Mention"; pub const NOTE: &str = "Note"; -pub const TOMBSTONE: &str = "Tombstone"; // Misc pub const PROPERTY_VALUE: &str = "PropertyValue";