Skip to content

Commit

Permalink
Merge pull request #3235 from omnivore-app/increase-feed-limit
Browse files Browse the repository at this point in the history
increase feed limit to 256
  • Loading branch information
sywhb authored Dec 11, 2023
2 parents 64fd0d7 + 36896a8 commit 4c42a55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/api/src/resolvers/subscriptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const subscribeResolver = authorized<
}

// create new rss subscription
const MAX_RSS_SUBSCRIPTIONS = 150
const MAX_RSS_SUBSCRIPTIONS = env.subscription.feed.max
// validate rss feed
const feed = await parseFeed(input.url)
if (!feed) {
Expand All @@ -232,7 +232,7 @@ export const subscribeResolver = authorized<
}
}

// limit number of rss subscriptions to 150
// limit number of rss subscriptions to max
const results = (await getRepository(Subscription).query(
`insert into omnivore.subscriptions (name, url, description, type, user_id, icon, auto_add_to_library, is_private)
select $1, $2, $3, $4, $5, $6, $7, $8 from omnivore.subscriptions
Expand Down Expand Up @@ -263,7 +263,7 @@ export const subscribeResolver = authorized<
// create a cloud task to fetch rss feed item for the new subscription
await enqueueRssFeedFetch({
userIds: [uid],
url: input.url,
url: feed.url,
subscriptionIds: [newSubscription.id],
scheduledDates: [new Date()], // fetch immediately
fetchedDates: [null],
Expand Down
15 changes: 15 additions & 0 deletions packages/api/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ interface BackendEnv {
pocket: {
consumerKey: string
}
subscription: {
feed: {
max: number
}
}
}

/***
Expand Down Expand Up @@ -167,6 +172,7 @@ const nullableEnvVars = [
'TRUST_PROXY',
'INTEGRATION_EXPORTER_URL',
'INTEGRATION_IMPORTER_URL',
'SUBSCRIPTION_FEED_MAX',
] // Allow some vars to be null/empty

/* If not in GAE and Prod/QA/Demo env (f.e. on localhost/dev env), allow following env vars to be null */
Expand Down Expand Up @@ -303,6 +309,14 @@ export function getEnv(): BackendEnv {
consumerKey: parse('POCKET_CONSUMER_KEY'),
}

const subscription = {
feed: {
max: parse('SUBSCRIPTION_FEED_MAX')
? parseInt(parse('SUBSCRIPTION_FEED_MAX'), 10)
: 256, // default to 256
},
}

return {
pg,
client,
Expand All @@ -323,6 +337,7 @@ export function getEnv(): BackendEnv {
azure,
gcp,
pocket,
subscription,
}
}

Expand Down

1 comment on commit 4c42a55

@vercel
Copy link

@vercel vercel bot commented on 4c42a55 Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.