diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c47c72..20b484f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `ipx add --list --category News ` puts a feed in the Directory for anyone to subscribe to, - and it stays there when its last subscriber leaves. + and it stays there when its last subscriber leaves. Run for a feed already in the catalogue, + it lists it or sets its category. - Feeds nobody subscribes to that are dead for a month or quiet for a year are removed, so the Directory lists feeds worth taking. diff --git a/src/main.rs b/src/main.rs index 140f0bc..13ff2ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -686,6 +686,19 @@ async fn add( 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)) { + // Listing a feed the catalogue already has, or giving it a category, is the point of + // asking again: it changes those, and nothing else. + if let Some(f) = cfg.feeds.get_mut(&existing.id) + && (list || category.is_some()) + { + f.listed |= list; + if category.is_some() { + f.category = category; + } + ctx.store_cfg(cfg).await?; + println!("{} is already in the catalogue; updated its Directory listing", existing.id); + return Ok(()); + } anyhow::bail!("already subscribed as {:?}", existing.id); } let id = add_one(ctx, &mut cfg, url, folder, keywords).await?;