diff --git a/plume-common/src/activity_pub/inbox.rs b/plume-common/src/activity_pub/inbox.rs index 5bcf5ed9..2537b1a4 100644 --- a/plume-common/src/activity_pub/inbox.rs +++ b/plume-common/src/activity_pub/inbox.rs @@ -196,84 +196,6 @@ where Inbox::NotHandled(ctx, json, InboxError::NoMatch) } - /// Registers an handler on this Inbox. - pub fn with(self, proxy: Option<&reqwest::Proxy>) -> Inbox<'a, C, E, R> - where - A: AsActor<&'a C> + FromId, - V: activitypub::Activity, - M: AsObject + FromId, - M::Output: Into, - { - if let Inbox::NotHandled(ctx, mut act, e) = self { - if serde_json::from_value::(act.clone()).is_ok() { - let act_clone = act.clone(); - let act_id = match act_clone["id"].as_str() { - Some(x) => x, - None => return Inbox::NotHandled(ctx, act, InboxError::InvalidID), - }; - - // Get the actor ID - let actor_id = match get_id(act["actor"].clone()) { - Some(x) => x, - None => return Inbox::NotHandled(ctx, act, InboxError::InvalidActor(None)), - }; - - if Self::is_spoofed_activity(&actor_id, &act) { - return Inbox::NotHandled(ctx, act, InboxError::InvalidObject(None)); - } - - // Transform this actor to a model (see FromId for details about the from_id function) - let actor = match A::from_id( - ctx, - &actor_id, - serde_json::from_value(act["actor"].clone()).ok(), - proxy, - ) { - Ok(a) => a, - // If the actor was not found, go to the next handler - Err((json, e)) => { - if let Some(json) = json { - act["actor"] = json; - } - return Inbox::NotHandled(ctx, act, InboxError::InvalidActor(Some(e))); - } - }; - - // Same logic for "object" - let obj_id = match get_id(act["object"].clone()) { - Some(x) => x, - None => return Inbox::NotHandled(ctx, act, InboxError::InvalidObject(None)), - }; - let obj = match M::from_id( - ctx, - &obj_id, - serde_json::from_value(act["object"].clone()).ok(), - proxy, - ) { - Ok(o) => o, - Err((json, e)) => { - if let Some(json) = json { - act["object"] = json; - } - return Inbox::NotHandled(ctx, act, InboxError::InvalidObject(Some(e))); - } - }; - - // Handle the activity - match obj.activity(ctx, actor, act_id) { - Ok(res) => Inbox::Handled(res.into()), - Err(e) => Inbox::Failed(e), - } - } else { - // If the Activity type is not matching the expected one for - // this handler, try with the next one. - Inbox::NotHandled(ctx, act, e) - } - } else { - self - } - } - /// Registers an handler on this Inbox. pub fn with07(self, proxy: Option<&reqwest::Proxy>) -> Self where