diff --git a/src/activitypub/activity.rs b/src/activitypub/activity.rs index 01770fd..956395a 100644 --- a/src/activitypub/activity.rs +++ b/src/activitypub/activity.rs @@ -60,18 +60,3 @@ pub struct Object { pub updated: Option>, pub url: Option, } - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Activity { - pub id: String, - - #[serde(rename = "type")] - pub activity_type: String, - - pub actor: String, - pub object: Value, - pub target: Option, - pub to: Option, - pub cc: Option, -} diff --git a/src/activitypub/handlers/undo.rs b/src/activitypub/handlers/undo.rs index 59c8c6f..c7bf9de 100644 --- a/src/activitypub/handlers/undo.rs +++ b/src/activitypub/handlers/undo.rs @@ -1,8 +1,8 @@ +use serde::Deserialize; use serde_json::Value; use tokio_postgres::GenericClient; use crate::activitypub::{ - activity::Activity, identifiers::parse_local_actor_id, receiver::find_object_id, vocabulary::{ANNOUNCE, FOLLOW, LIKE}, @@ -27,10 +27,16 @@ use crate::models::{ }; use super::HandlerResult; +#[derive(Deserialize)] +struct Undo { + actor: String, + object: Value, +} + async fn handle_undo_follow( config: &Config, db_client: &mut impl GenericClient, - activity: Activity, + activity: Undo, ) -> HandlerResult { let source_profile = get_profile_by_remote_actor_id( db_client, @@ -57,7 +63,7 @@ pub async fn handle_undo( db_client: &mut impl GenericClient, activity: Value, ) -> HandlerResult { - let activity: Activity = serde_json::from_value(activity) + let activity: Undo = serde_json::from_value(activity) .map_err(|_| ValidationError("unexpected activity structure"))?; if let Some(FOLLOW) = activity.object["type"].as_str() { // Object type is currently required for processing Undo(Follow)