Handle Delete activities that don't have object type

This commit is contained in:
silverpill 2021-11-19 00:05:39 +00:00
parent 3b5ec45991
commit bbf696fe6e
3 changed files with 11 additions and 6 deletions

View file

@ -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)

View file

@ -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 {

View file

@ -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";