From 9a5bb8a189d35206fd5dd94693a8be20fc8e1c1c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 27 Oct 2021 17:50:55 -0400 Subject: [PATCH] Fixing shared inbox bug. Fixes #1865 --- api_tests/src/comment.spec.ts | 6 +++--- crates/apub/src/http/community.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index fad2226e2..451e83de1 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -360,14 +360,14 @@ test('Check 3 instance shared inbox bug', async () => { // Make sure alpha sees it let alphaPost2 = await getPost(alpha, alphaPost.post.id); - // TODO remove this after - console.log(alphaPost2); expect(alphaPost2.comments[0].comment.content).toBe(commentContent); - expect(alphaPost2.comments[0].community.local).toBe(true); + expect(alphaPost2.comments[0].community.local).toBe(false); expect(alphaPost2.comments[0].creator.local).toBe(false); expect(alphaPost2.comments[0].counts.score).toBe(1); assertCommentFederation(alphaPost2.comments[0], commentRes.comment_view); + await unfollowRemotes(alpha); + await unfollowRemotes(gamma); }); test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedded comments, A subs to B, B updates the lowest level comment, A fetches both the post and all the inreplyto comments for that post.', async () => { diff --git a/crates/apub/src/http/community.rs b/crates/apub/src/http/community.rs index 1e10e3844..65a9459a4 100644 --- a/crates/apub/src/http/community.rs +++ b/crates/apub/src/http/community.rs @@ -83,12 +83,6 @@ pub async fn community_inbox( receive_group_inbox(activity.clone(), request, &context).await?; - if let GroupInboxActivities::AnnouncableActivities(announcable) = activity { - let community = extract_community(&announcable.cc(), &context, &mut 0).await?; - if community.local { - AnnounceActivity::send(announcable, &community, vec![], &context).await?; - } - } Ok(HttpResponse::Ok().finish()) } @@ -97,6 +91,12 @@ pub(in crate::http) async fn receive_group_inbox( request: HttpRequest, context: &LemmyContext, ) -> Result { + if let GroupInboxActivities::AnnouncableActivities(announcable) = activity.clone() { + let community = extract_community(&announcable.cc(), context, &mut 0).await?; + if community.local { + AnnounceActivity::send(announcable, &community, vec![], context).await?; + } + } receive_activity(request, activity.clone(), context).await }