Skip to content

Commit ecf796d

Browse files
authored
Excluded reposts from global feed (#1407)
ref https://linear.app/ghost/issue/BER-2935/discovery-feed-from-top-publishers - we only want to show original posts in the global feed, not reposts
1 parent 625bcc8 commit ecf796d

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

src/feed/feed.service.integration.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,49 @@ describe('FeedService', () => {
992992
// Cleanup
993993
TOP_PUBLISHERS.delete(topPublisherAccount.id);
994994
});
995+
996+
it('should NOT add reposts to the global feed', async () => {
997+
const feedService = new FeedService(client, moderationService);
998+
999+
// Create the global feed account
1000+
const globalAccount = await createInternalAccount(
1001+
'ap-global-feed.ghost.io',
1002+
);
1003+
1004+
// Create a top publisher
1005+
const topPublisherAccount = await createInternalAccount(
1006+
'top-publisher-reposter.com',
1007+
);
1008+
TOP_PUBLISHERS.add(topPublisherAccount.id);
1009+
1010+
// Create another account that authors an article
1011+
const articleAuthor =
1012+
await createInternalAccount('article-author.com');
1013+
1014+
// Create an article
1015+
const articlePost = await createPost(articleAuthor, {
1016+
type: PostType.Article,
1017+
audience: Audience.Public,
1018+
});
1019+
await postRepository.save(articlePost);
1020+
1021+
// Top publisher reposts the article
1022+
articlePost.addRepost(topPublisherAccount);
1023+
await postRepository.save(articlePost);
1024+
1025+
// Add the repost to feeds
1026+
await feedService.addPostToFeeds(
1027+
articlePost as PublicPost,
1028+
topPublisherAccount.id,
1029+
);
1030+
1031+
// Verify the repost was NOT added to the global feed
1032+
const globalFeed = await getFeedDataForAccount(globalAccount);
1033+
expect(globalFeed).toHaveLength(0);
1034+
1035+
// Cleanup
1036+
TOP_PUBLISHERS.delete(topPublisherAccount.id);
1037+
});
9951038
});
9961039

9971040
describe('removePostFromFeeds', () => {

src/feed/feed.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,15 @@ export class FeedService {
415415
repostedBy ?? undefined,
416416
);
417417

418-
// Add post to the global discovery feed if it's long-form and authored by a top publisher
418+
// Add post to the global discovery feed if:
419+
// - it's long-form
420+
// - not a repost
421+
// - authored by a top publisher
419422
const globalFeedUserId = await this.getGlobalFeedUserId();
420423
if (
421424
globalFeedUserId !== null &&
422425
post.type === PostType.Article &&
426+
repostedBy === null &&
423427
isTopPublisher(post.author.id)
424428
) {
425429
userIds.push(globalFeedUserId);

0 commit comments

Comments
 (0)