From 884307ac60a27c935446110a72ef957f4d94b104 Mon Sep 17 00:00:00 2001 From: phiresky Date: Fri, 1 Sep 2023 12:41:03 +0000 Subject: [PATCH] filter follow+report activities by local --- crates/apub/src/activities/community/report.rs | 7 +++++-- crates/apub/src/activities/following/follow.rs | 7 +++++-- crates/apub/src/activities/following/undo_follow.rs | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/apub/src/activities/community/report.rs b/crates/apub/src/activities/community/report.rs index aee8eb1b6..232aa0f51 100644 --- a/crates/apub/src/activities/community/report.rs +++ b/crates/apub/src/activities/community/report.rs @@ -50,8 +50,11 @@ impl Report { id: id.clone(), audience: Some(community.id().into()), }; - // todo: this should probably filter and only send if the community is remote? - let inbox = ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox()); + let inbox = if community.local { + ActivitySendTargets::empty() + } else { + ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox()) + }; send_lemmy_activity(&context, report, &actor, inbox, false).await } } diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index d2754dd58..6f6e2718f 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -62,8 +62,11 @@ impl Follow { .ok(); let follow = Follow::new(actor, community, context)?; - // todo: this should probably filter and only send if the community is remote? - let inbox = ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox()); + let inbox = if community.local { + ActivitySendTargets::empty() + } else { + ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox()) + }; send_lemmy_activity(context, follow, actor, inbox, true).await } } diff --git a/crates/apub/src/activities/following/undo_follow.rs b/crates/apub/src/activities/following/undo_follow.rs index b3718a88e..2f1c5a76b 100644 --- a/crates/apub/src/activities/following/undo_follow.rs +++ b/crates/apub/src/activities/following/undo_follow.rs @@ -41,8 +41,11 @@ impl UndoFollow { &context.settings().get_protocol_and_hostname(), )?, }; - // todo: this should probably filter and only send if the community is remote? - let inbox = ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox()); + let inbox = if community.local { + ActivitySendTargets::empty() + } else { + ActivitySendTargets::to_inbox(community.shared_inbox_or_inbox()) + }; send_lemmy_activity(context, undo, actor, inbox, true).await } }