use user provided url for feed added

This commit is contained in:
Hongbo Wu
2024-01-19 16:28:37 +08:00
parent d135a7fe6a
commit 35805e6e8f

View File

@ -193,15 +193,8 @@ export const subscribeResolver = authorized<
env: env.server.apiEnv,
},
})
// validate rss feed
const feed = await parseFeed(input.url)
if (!feed) {
return {
errorCodes: [SubscribeErrorCode.NotFound],
}
}
const feedUrl = feed.url
// use user provided url
const feedUrl = input.url
try {
validateUrl(feedUrl)
} catch (error) {
@ -212,6 +205,14 @@ export const subscribeResolver = authorized<
}
}
// validate rss feed
const feed = await parseFeed(feedUrl)
if (!feed) {
return {
errorCodes: [SubscribeErrorCode.NotFound],
}
}
// find existing subscription
const existingSubscription = await getRepository(Subscription).findOneBy({
url: In([feedUrl, input.url]), // check both user provided url and parsed url