Handle Delete activities that don't have object type
This commit is contained in:
parent
3b5ec45991
commit
bbf696fe6e
3 changed files with 11 additions and 6 deletions
|
@ -79,7 +79,7 @@ The following activities are supported:
|
||||||
- Accept(Follow)
|
- Accept(Follow)
|
||||||
- Reject(Follow)
|
- Reject(Follow)
|
||||||
- Create(Note)
|
- Create(Note)
|
||||||
- Delete(Tombstone)
|
- Delete(Note)
|
||||||
- Like(Note)
|
- Like(Note)
|
||||||
- Follow(Person)
|
- Follow(Person)
|
||||||
- Undo(Follow)
|
- Undo(Follow)
|
||||||
|
|
|
@ -292,10 +292,16 @@ pub async fn receive_activity(
|
||||||
.map_err(|_| ValidationError("invalid object"))?;
|
.map_err(|_| ValidationError("invalid object"))?;
|
||||||
process_note(config, db_client, object).await?;
|
process_note(config, db_client, object).await?;
|
||||||
},
|
},
|
||||||
(DELETE, TOMBSTONE) => {
|
(DELETE, _) => {
|
||||||
let object: Object = serde_json::from_value(activity.object)
|
let object_id = match activity.object.as_str() {
|
||||||
.map_err(|_| ValidationError("invalid object"))?;
|
Some(object_id) => object_id.to_owned(),
|
||||||
let post = get_post_by_object_id(db_client, &object.id).await?;
|
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 deletion_queue = delete_post(db_client, &post.id).await?;
|
||||||
let config = config.clone();
|
let config = config.clone();
|
||||||
actix_rt::spawn(async move {
|
actix_rt::spawn(async move {
|
||||||
|
|
|
@ -19,7 +19,6 @@ pub const DOCUMENT: &str = "Document";
|
||||||
pub const IMAGE: &str = "Image";
|
pub const IMAGE: &str = "Image";
|
||||||
pub const MENTION: &str = "Mention";
|
pub const MENTION: &str = "Mention";
|
||||||
pub const NOTE: &str = "Note";
|
pub const NOTE: &str = "Note";
|
||||||
pub const TOMBSTONE: &str = "Tombstone";
|
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
pub const PROPERTY_VALUE: &str = "PropertyValue";
|
pub const PROPERTY_VALUE: &str = "PropertyValue";
|
||||||
|
|
Loading…
Reference in a new issue