Handle incoming Delete() activities
This commit is contained in:
parent
e48670c28b
commit
ce551e9c8b
2 changed files with 15 additions and 0 deletions
|
@ -14,6 +14,7 @@ use crate::models::posts::queries::{
|
||||||
create_post,
|
create_post,
|
||||||
get_post_by_id,
|
get_post_by_id,
|
||||||
get_post_by_object_id,
|
get_post_by_object_id,
|
||||||
|
delete_post,
|
||||||
};
|
};
|
||||||
use crate::models::profiles::queries::{
|
use crate::models::profiles::queries::{
|
||||||
get_profile_by_actor_id,
|
get_profile_by_actor_id,
|
||||||
|
@ -255,6 +256,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) => {
|
||||||
|
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, _) => {
|
(LIKE, _) => {
|
||||||
let author = get_or_fetch_profile_by_actor_id(
|
let author = get_or_fetch_profile_by_actor_id(
|
||||||
db_client,
|
db_client,
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
/// https://www.w3.org/TR/activitystreams-vocabulary/
|
||||||
|
|
||||||
// Activity types
|
// Activity types
|
||||||
pub const ACCEPT: &str = "Accept";
|
pub const ACCEPT: &str = "Accept";
|
||||||
pub const CREATE: &str = "Create";
|
pub const CREATE: &str = "Create";
|
||||||
|
pub const DELETE: &str = "Delete";
|
||||||
pub const FOLLOW: &str = "Follow";
|
pub const FOLLOW: &str = "Follow";
|
||||||
pub const LIKE: &str = "Like";
|
pub const LIKE: &str = "Like";
|
||||||
pub const REJECT: &str = "Reject";
|
pub const REJECT: &str = "Reject";
|
||||||
|
@ -15,6 +18,7 @@ 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