Handle incoming Delete() activities

This commit is contained in:
silverpill 2021-11-12 14:51:03 +00:00
parent e48670c28b
commit ce551e9c8b
2 changed files with 15 additions and 0 deletions

View file

@ -14,6 +14,7 @@ use crate::models::posts::queries::{
create_post,
get_post_by_id,
get_post_by_object_id,
delete_post,
};
use crate::models::profiles::queries::{
get_profile_by_actor_id,
@ -255,6 +256,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?;
let deletion_queue = delete_post(db_client, &post.id).await?;
let config = config.clone();
actix_rt::spawn(async move {
deletion_queue.process(&config).await;
});
},
(LIKE, _) => {
let author = get_or_fetch_profile_by_actor_id(
db_client,

View file

@ -1,6 +1,9 @@
/// https://www.w3.org/TR/activitystreams-vocabulary/
// Activity types
pub const ACCEPT: &str = "Accept";
pub const CREATE: &str = "Create";
pub const DELETE: &str = "Delete";
pub const FOLLOW: &str = "Follow";
pub const LIKE: &str = "Like";
pub const REJECT: &str = "Reject";
@ -15,6 +18,7 @@ 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";