mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
check both user provided url and parsed feed url when looking for existing subscription
This commit is contained in:
parent
e9f0725208
commit
696de8ea50
1 changed files with 13 additions and 11 deletions
|
|
@ -193,9 +193,18 @@ export const subscribeResolver = authorized<
|
|||
},
|
||||
})
|
||||
|
||||
// validate rss feed
|
||||
const feed = await parseFeed(input.url)
|
||||
if (!feed) {
|
||||
return {
|
||||
errorCodes: [SubscribeErrorCode.NotFound],
|
||||
}
|
||||
}
|
||||
const feedUrl = feed.url
|
||||
|
||||
// find existing subscription
|
||||
const existingSubscription = await getRepository(Subscription).findOneBy({
|
||||
url: input.url,
|
||||
url: feedUrl,
|
||||
user: { id: uid },
|
||||
type: SubscriptionType.Rss,
|
||||
})
|
||||
|
|
@ -218,7 +227,7 @@ export const subscribeResolver = authorized<
|
|||
// create a cloud task to fetch rss feed item for resub subscription
|
||||
await enqueueRssFeedFetch({
|
||||
userIds: [uid],
|
||||
url: input.url,
|
||||
url: feedUrl,
|
||||
subscriptionIds: [updatedSubscription.id],
|
||||
scheduledDates: [new Date()], // fetch immediately
|
||||
fetchedDates: [updatedSubscription.lastFetchedAt || null],
|
||||
|
|
@ -234,13 +243,6 @@ export const subscribeResolver = authorized<
|
|||
|
||||
// create new rss subscription
|
||||
const MAX_RSS_SUBSCRIPTIONS = env.subscription.feed.max
|
||||
// validate rss feed
|
||||
const feed = await parseFeed(input.url)
|
||||
if (!feed) {
|
||||
return {
|
||||
errorCodes: [SubscribeErrorCode.NotFound],
|
||||
}
|
||||
}
|
||||
|
||||
// limit number of rss subscriptions to max
|
||||
const results = (await getRepository(Subscription).query(
|
||||
|
|
@ -251,7 +253,7 @@ export const subscribeResolver = authorized<
|
|||
returning *;`,
|
||||
[
|
||||
feed.title,
|
||||
feed.url,
|
||||
feedUrl,
|
||||
feed.description,
|
||||
SubscriptionType.Rss,
|
||||
uid,
|
||||
|
|
@ -275,7 +277,7 @@ export const subscribeResolver = authorized<
|
|||
// create a cloud task to fetch rss feed item for the new subscription
|
||||
await enqueueRssFeedFetch({
|
||||
userIds: [uid],
|
||||
url: feed.url,
|
||||
url: feedUrl,
|
||||
subscriptionIds: [newSubscription.id],
|
||||
scheduledDates: [new Date()], // fetch immediately
|
||||
fetchedDates: [null],
|
||||
|
|
|
|||
Loading…
Reference in a new issue