Look up derived feeds everywhere, not just in config

Moving OPML feeds into the database left several call sites still
searching config.toml only, so anything inside a subscription looked
unsubscribed: Download failed outright, status and the startup line
counted 3 feeds instead of 85, add could duplicate or collide with a
derived feed, and rm could not remove one.

The first grep for this missed the failing call because the method chain
spans lines; searching with newlines collapsed found all of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdXho5tTkjFLeUXKbEjKBh
This commit is contained in:
2026-09-10 16:55:54 +00:00
parent 665d5b8ecb
commit 4429f1119c
3 changed files with 61 additions and 11 deletions

View File

@@ -398,8 +398,12 @@ async fn add_feed(
Json(body): Json<NewFeed>,
) -> Result<Json<serde_json::Value>, ApiError> {
let mut cfg = (*state.ctx.cfg()).clone();
if let Some((id, _)) = cfg.feeds.iter().find(|(_, f)| f.url == body.url) {
return Ok(Json(serde_json::json!({ "id": id, "existing": true })));
// Derived feeds count as subscribed: adding one an OPML already lists would duplicate it.
if let Some(existing) = crate::subscriptions(&state.ctx)?
.into_iter()
.find(|s| s.cfg.url == body.url)
{
return Ok(Json(serde_json::json!({ "id": existing.id, "existing": true })));
}
let id = crate::add_one(&state.ctx, &mut cfg, &body.url, body.folder, body.keywords).await?;
cfg.save(&state.config_path)?;