Skip to content

Commit

Permalink
fix: use followed users/sources for custom feed
Browse files Browse the repository at this point in the history
  • Loading branch information
idoshamun committed Dec 20, 2024
1 parent 5a0421c commit 2124562
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
20 changes: 20 additions & 0 deletions __tests__/feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4292,6 +4292,24 @@ describe('query customFeed', () => {
},
},
]);
await con.getRepository(ContentPreferenceUser).save([
{
feedId: 'cf1',
referenceUserId: '2',
referenceId: '2',
status: ContentPreferenceStatus.Follow,
userId: '1',
},
]);
await con.getRepository(ContentPreferenceSource).save([
{
feedId: 'cf1',
sourceId: 'a',
referenceId: 'a',
status: ContentPreferenceStatus.Follow,
userId: '1',
},
]);
await con.getRepository(ContentPreferenceKeyword).save([
{
feedId: 'cf1',
Expand Down Expand Up @@ -4438,6 +4456,8 @@ describe('query customFeed', () => {
total_pages: 1,
fresh_page_size: '4',
allowed_tags: ['webdev', 'html', 'data'],
allowed_sources: ['a'],
allowed_author_ids: ['2'],
feed_config_name: FeedConfigName.CustomFeedV1,
disable_engagement_filter: false,
})
Expand Down
9 changes: 7 additions & 2 deletions src/integrations/feed/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { Context } from '../../Context';
export type Options = {
includeAllowedTags?: boolean;
includeBlockedTags?: boolean;
includeAllowedSources?: boolean;
includeBlockedSources?: boolean;
includeAllowedUsers?: boolean;
includeSourceMemberships?: boolean;
includePostTypes?: boolean;
includeContentCuration?: boolean;
Expand Down Expand Up @@ -115,8 +117,11 @@ const addFiltersToConfig = ({
if (filters.followingSources?.length && opts.includeFollowedSources) {
baseConfig.followed_sources = filters.followingSources;
}
if (filters.followingUsers?.length && opts.includeFollowedUsers) {
baseConfig.followed_user_ids = filters.followingUsers;
if (filters.followingSources?.length && opts.includeAllowedSources) {
baseConfig.allowed_sources = filters.followingSources;
}
if (filters.followingUsers?.length && opts.includeAllowedUsers) {
baseConfig.allowed_author_ids = filters.followingUsers;
}

return baseConfig;
Expand Down
2 changes: 2 additions & 0 deletions src/integrations/feed/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ export type FeedConfig = {
fresh_page_size?: string;
allowed_tags?: string[];
blocked_tags?: string[];
allowed_sources?: string[];
blocked_sources?: string[];
allowed_post_types?: string[];
allowed_content_curations?: string[];
blocked_title_words?: string[];
allowed_author_ids?: string[];
followed_user_ids?: string[];
followed_sources?: string[];
squad_ids?: string[];
Expand Down
2 changes: 2 additions & 0 deletions src/schema/feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,8 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
includeBlockedTags: true,
includeContentCuration: true,
includeBlockedWords: true,
includeAllowedUsers: true,
includeAllowedSources: true,
feedId: feedId,
},
),
Expand Down

0 comments on commit 2124562

Please sign in to comment.