From 80ce7f19ec82e04d0be653b428f9c28c4ddcf651 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 9 Apr 2021 14:29:39 +0200 Subject: [PATCH] Make Undo/Block work for remote mods --- crates/apub/src/activities/send/community.rs | 1 + crates/apub_receive/src/inbox/community_inbox.rs | 13 ++++++++++++- crates/apub_receive/src/inbox/shared_inbox.rs | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/apub/src/activities/send/community.rs b/crates/apub/src/activities/send/community.rs index 5b93cbb2b..faaaef952 100644 --- a/crates/apub/src/activities/send/community.rs +++ b/crates/apub/src/activities/send/community.rs @@ -208,6 +208,7 @@ impl CommunityType for Community { .set_to(public()) .set_many_ccs(ccs); + dbg!(&object_actor_inbox); send_to_community_followers(announce, self, object_actor_inbox, context).await?; Ok(()) diff --git a/crates/apub_receive/src/inbox/community_inbox.rs b/crates/apub_receive/src/inbox/community_inbox.rs index f22f3fe05..84b016991 100644 --- a/crates/apub_receive/src/inbox/community_inbox.rs +++ b/crates/apub_receive/src/inbox/community_inbox.rs @@ -241,7 +241,18 @@ pub(crate) async fn community_receive_message( if do_announce { // Check again that the activity is public, just to be sure verify_is_addressed_to_public(&activity)?; - let object_actor = activity.object().clone().single_xsd_any_uri(); + let mut object_actor = activity.object().clone().single_xsd_any_uri(); + // If activity is something like Undo/Block, we need to access activity.object.object + if object_actor.is_none() { + object_actor = activity + .object() + .as_one() + .map(|a| ActorAndObject::from_any_base(a.to_owned()).ok()) + .flatten() + .flatten() + .map(|a: ActorAndObject| a.object().to_owned().single_xsd_any_uri()) + .flatten(); + } to_community .send_announce(activity.into_any_base()?, object_actor, context) .await?; diff --git a/crates/apub_receive/src/inbox/shared_inbox.rs b/crates/apub_receive/src/inbox/shared_inbox.rs index cd4ae145a..db060247c 100644 --- a/crates/apub_receive/src/inbox/shared_inbox.rs +++ b/crates/apub_receive/src/inbox/shared_inbox.rs @@ -34,6 +34,7 @@ pub enum ValidTypes { Remove, Announce, Add, + Block, } // TODO: this isnt entirely correct, cause some of these receive are not ActorAndObject,