Add only what is a feed or links one; refuse the rest (#102)
Adding an address looked for the feed a web page links and, finding none, added the address as it was: every check then failed, and the sidebar called it a feed that had moved. cnn.com is one; its page links no feed. find_feed replaces feed_behind_page: the address is added if it is a feed or an OPML list, the feed its page links if it is a web page that links one (and that is a feed), and otherwise the add is refused with the reason, from the web page (400, the dialog stays open) and from `ipx add`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -661,7 +661,7 @@ async fn add(
|
||||
keywords: Vec<String>,
|
||||
) -> Result<()> {
|
||||
let mut cfg = (*ctx.cfg()).clone();
|
||||
let url = &feed::feed_behind_page(&ctx.client, &feed::expand_input(url)).await;
|
||||
let url = &feed::find_feed(&ctx.client, &feed::expand_input(url)).await?;
|
||||
// Includes feeds derived from an OPML, or the same show could be added twice.
|
||||
if let Some(existing) = subscriptions(ctx).await?.iter().find(|s| feed::same_feed(&s.cfg.url, url)) {
|
||||
anyhow::bail!("already subscribed as {:?}", existing.id);
|
||||
@@ -672,8 +672,8 @@ async fn add(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the new feed id. The title needs a fetch, so a feed that cannot be reached is
|
||||
/// still added -- under a slug derived from its URL -- rather than refused.
|
||||
/// Returns the new feed id. Adding checks the address is a feed first (`feed::find_feed`); this
|
||||
/// still names one it cannot read from its URL rather than failing.
|
||||
pub async fn add_one(
|
||||
ctx: &Ctx,
|
||||
cfg: &mut config::Config,
|
||||
|
||||
Reference in New Issue
Block a user