DeadAir is off for every feed until turned on for it (#171)
There was one switch for everything, with a feed kept out by hand; any feed already subscribed would have been in it the moment the switch was turned on. Now each feed, or the group it came in, is turned on by itself, and a feed of a group turned on can still be kept out. The general switch and /api/me's deadair are gone; /api/me keeps deadair_saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
18
src/web.rs
18
src/web.rs
@@ -375,12 +375,10 @@ async fn me(
|
||||
let url = state.ctx.cfg().web.sign_out_url.clone();
|
||||
let sign_out = (by_proxy && !url.is_empty()).then_some(url);
|
||||
let blocked = state.ctx.db.blocklist(user.id, "").await.unwrap_or_default();
|
||||
let prefs = state.ctx.db.deadair_prefs(Some(user.id)).await.unwrap_or_default();
|
||||
let deadair = prefs.iter().any(|(_, f, on)| f.is_empty() && *on);
|
||||
let saved = state.ctx.db.deadair_total(user.id).await.unwrap_or(0) / 1000;
|
||||
Json(serde_json::json!({
|
||||
"name": user.name, "admin": user.is_admin, "sign_out": sign_out, "blocked": blocked,
|
||||
"deadair": deadair, "deadair_saved": saved,
|
||||
"deadair_saved": saved,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -388,8 +386,6 @@ async fn me(
|
||||
struct MePatch {
|
||||
/// Words that hide an item in every feed you read.
|
||||
blocked: Option<Vec<String>>,
|
||||
/// DeadAir's switch, beside the speed (#171).
|
||||
deadair: Option<bool>,
|
||||
}
|
||||
|
||||
/// Saves the block list for every feed. The theme is not the account's: each browser keeps its
|
||||
@@ -402,9 +398,6 @@ async fn patch_me(
|
||||
if let Some(words) = body.blocked {
|
||||
state.ctx.db.set_blocklist(user.id, "", &clean_words(words)?).await?;
|
||||
}
|
||||
if let Some(on) = body.deadair {
|
||||
state.ctx.db.set_deadair(user.id, "", Some(on)).await?;
|
||||
}
|
||||
Ok(StatusCode::NO_CONTENT)
|
||||
}
|
||||
|
||||
@@ -779,8 +772,7 @@ struct FeedRow {
|
||||
keywords: Vec<String>,
|
||||
/// Your words that hide an item of this feed, beside your list for every feed.
|
||||
blocked: Vec<String>,
|
||||
/// Played from DeadAir's copies when your switch is on: false for a feed you keep out, by
|
||||
/// itself or by its group.
|
||||
/// Played from DeadAir's copies: on for this feed or its group, off until you turn it on.
|
||||
deadair: bool,
|
||||
allow_explicit: bool,
|
||||
auto_download: bool,
|
||||
@@ -872,7 +864,7 @@ async fn feed_rows(state: &WebState, user: &crate::db::User, only: Option<&str>)
|
||||
.or_else(|| up.and_then(|u| u.keywords.clone()))
|
||||
.unwrap_or_else(|| feed.keywords.clone()),
|
||||
blocked,
|
||||
deadair: deadair.get(id).or_else(|| feed.group.as_deref().and_then(|g| deadair.get(g))).copied().unwrap_or(true),
|
||||
deadair: deadair.get(id).or_else(|| feed.group.as_deref().and_then(|g| deadair.get(g))).copied().unwrap_or(false),
|
||||
allow_explicit: mine
|
||||
.allow_explicit
|
||||
.or(up.and_then(|u| u.allow_explicit))
|
||||
@@ -1565,8 +1557,8 @@ struct FeedPatch {
|
||||
#[serde(default, deserialize_with = "double_option")]
|
||||
max_new_per_check: Option<Option<usize>>,
|
||||
pinned: Option<bool>,
|
||||
/// False keeps the feed out of DeadAir, true lets it in under a group kept out, null
|
||||
/// follows the group again.
|
||||
/// True plays the feed from DeadAir's copies, false keeps it out (of its group's too), null
|
||||
/// follows its group again (#171).
|
||||
#[serde(default, deserialize_with = "double_option")]
|
||||
deadair: Option<Option<bool>>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user