A playlist is the episodes of the podcasts chosen, those set to play first ahead of the rest, newest or oldest first, unplayed only or all, kept up to date by itself (table `playlists`, /api/playlists). It sits in a folder of its own in the feed list, as Signals do. Played from one, an episode goes on to the playlist's next once Up Next has nothing. The priority ids are written into the ORDER BY, which the page query uses twice, so they are quoted there rather than bound; they are also only ever feed ids this person subscribes to. The folder row first borrowed Signals' `sigs` class, which the tests use to mean Signals' folder; four Signals tests failed until it had its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
588 lines
22 KiB
Rust
588 lines
22 KiB
Rust
//! The database's tables as SeaORM entities: the one description of the schema, from which
|
|
//! `Db::open` creates what a database is missing, on SQLite or Postgres alike (see
|
|
//! `db::create_missing`). Times are Unix seconds.
|
|
|
|
pub mod feeds {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "feeds")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub id: String,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub url: String,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub title: Option<String>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub image: Option<String>,
|
|
/// The channel's first <itunes:category>, for the Directory.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub category: Option<String>,
|
|
/// What the feed says it is, as it says it, for its page in the Directory. Added after
|
|
/// the table was, so `create_missing` adds it to a database without it.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub description: Option<String>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub etag: Option<String>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub last_modified: Option<String>,
|
|
pub last_checked: Option<i64>,
|
|
pub ttl_mins: Option<i64>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub last_error: Option<String>,
|
|
/// When the current run of failures began; NULL while the feed is healthy. Kept through
|
|
/// repeated failures so the UI can tell a blip (macmanx: failed once, fine an hour
|
|
/// later) from a feed that has been down for a day.
|
|
pub error_since: Option<i64>,
|
|
/// Came from a subscribed OPML that no longer lists it, but has downloads, so kept.
|
|
#[sea_orm(default_value = false)]
|
|
pub orphaned: bool,
|
|
/// The OPML subscription this feed came from.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub group_id: Option<String>,
|
|
/// Derived from an OPML and not written to config.toml. Writing 80-odd generated entries
|
|
/// into a hand-edited file made it unreadable; the OPML is the source of truth, so they
|
|
/// are re-derived instead. Customising one promotes it to config.
|
|
#[sea_orm(default_value = false)]
|
|
pub managed: bool,
|
|
/// SHA-256 of the body last read, in hex: the same body again is read as "not modified"
|
|
/// (#242). Added after the table was, so `create_missing` adds it, and `same_since`.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub body_hash: Option<String>,
|
|
/// When the body last changed: the longer ago, the less often the feed is checked (#242).
|
|
pub same_since: Option<i64>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
pub mod entries {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "entries")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub guid: String,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub title: Option<String>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub link: Option<String>,
|
|
pub published: Option<i64>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub description: Option<String>,
|
|
pub first_seen: i64,
|
|
/// The item's Markdown, when its feed sends it beside the HTML (#285).
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub markdown: Option<String>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub image: Option<String>,
|
|
pub duration: Option<i64>,
|
|
pub episode: Option<i64>,
|
|
pub season: Option<i64>,
|
|
/// The title and the text without markup, lowercased and cut short, which search reads
|
|
/// (#459); none until search.rs makes it.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub search_text: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
pub mod enclosures {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "enclosures")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i64,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub guid: String,
|
|
/// The dedupe key, and the reason one file serves every subscriber. A reaped file keeps
|
|
/// its row with path NULL and state 'reaped', so a purged episode is never fetched again.
|
|
#[sea_orm(unique, column_type = "Text")]
|
|
pub url: String,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub mime: Option<String>,
|
|
pub length: Option<i64>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub path: Option<String>,
|
|
/// 'pending' is queued: a scan downloads it on its own. 'held' is listed but outside the
|
|
/// feed's newest max_new_per_check, or its feed downloads nothing automatically; it can
|
|
/// be downloaded by hand (`Db::hold_back`). 'skipped' is filtered out ('last_error' says
|
|
/// why), then 'downloading', 'done', 'error', 'reaped'.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub state: String,
|
|
#[sea_orm(default_value = 0)]
|
|
pub bytes_done: i64,
|
|
pub downloaded_at: Option<i64>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub last_error: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
pub mod users {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "users")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i64,
|
|
/// Unique without regard to case: `db::create_missing` adds the index on lower(name), which
|
|
/// works the same on both databases where SQLite's COLLATE NOCASE does not.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub name: String,
|
|
/// NULL for someone who only ever arrives through the proxy: there is no password to
|
|
/// check, and leaving it empty is not the same as leaving it unset.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub pass_hash: Option<String>,
|
|
#[sea_orm(default_value = false)]
|
|
pub is_admin: bool,
|
|
/// For whoever maintains the server. NULL where it is not known.
|
|
pub created: Option<i64>,
|
|
pub last_login: Option<i64>,
|
|
/// The theme chosen in Settings, and light, dark or auto. NULL until one is chosen.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub theme: Option<String>,
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub theme_mode: Option<String>,
|
|
/// Their own TypeSafe key, which Jev judges their Signals' items on (#254). Never sent
|
|
/// back to the page.
|
|
// shortcut: kept as it is, since every call needs it whole; encrypt it with a key of the
|
|
// server's if the database is ever shared with anything else.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub typesafe_key: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
/// A table of one person's rows, gone when they are.
|
|
macro_rules! owned_by_user {
|
|
() => {
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::users::Entity",
|
|
from = "Column::UserId",
|
|
to = "super::users::Column::Id",
|
|
on_delete = "Cascade"
|
|
)]
|
|
User,
|
|
}
|
|
|
|
impl Related<super::users::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::User.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
};
|
|
}
|
|
|
|
/// What one person wants from a feed. The feed, its items and its files are shared; this is the
|
|
/// part that is not. NULL in a column means: follow the feed's own setting.
|
|
pub mod subscriptions {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "subscriptions")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
/// JSON array of strings; NULL follows the feed.
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub keywords: Option<String>,
|
|
pub auto_download: Option<bool>,
|
|
pub allow_explicit: Option<bool>,
|
|
pub max_new_per_check: Option<i64>,
|
|
/// Pinned to the top of this person's feed list, a feed inside a folder included.
|
|
#[sea_orm(default_value = false)]
|
|
pub pinned: bool,
|
|
/// A feed from an OPML or Patreon list this person keeps when the list drops it, or when
|
|
/// they leave the list: it becomes a feed of its own instead of going (#280).
|
|
#[sea_orm(default_value = false)]
|
|
pub kept: bool,
|
|
/// Left out of All Subscriptions: this feed, or on an OPML or Patreon creator every show
|
|
/// in it (#288).
|
|
#[sea_orm(default_value = false)]
|
|
pub hide_from_all: bool,
|
|
/// Left out of every Signal, and never put to Jev for them, as `hide_from_all` (#289).
|
|
#[sea_orm(default_value = false)]
|
|
pub hide_from_signals: bool,
|
|
/// Every item of the feed first seen before this is read by this person (#347): unread
|
|
/// lists start here instead of reading the whole back catalogue. NULL knows nothing, and
|
|
/// the daily reap moves it up (`Db::advance_unread_from`).
|
|
pub unread_from: Option<i64>,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// Read, kept and how far in. One row per person per item, created on first touch; an item
|
|
/// nobody has touched has no row at all, which is what unread means.
|
|
pub mod entry_state {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "entry_state")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub guid: String,
|
|
#[sea_orm(default_value = false)]
|
|
pub read: bool,
|
|
#[sea_orm(default_value = false)]
|
|
pub flagged: bool,
|
|
#[sea_orm(default_value = 0)]
|
|
pub position: i64,
|
|
/// The length this person's player measured, beside the position it is measured against.
|
|
pub duration: Option<i64>,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// Up Next (#473): the episodes someone has lined up to play, in order. Per person, and on the
|
|
/// server so the phone and the browser play through the same one.
|
|
pub mod queue {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "queue")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub guid: String,
|
|
pub pos: i64,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// Smart playlists (#476): episodes of the podcasts chosen, kept up to date by themselves. The
|
|
/// priority podcasts' episodes come first.
|
|
pub mod playlists {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "playlists")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub name: String,
|
|
/// JSON array of feed ids.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub feeds: String,
|
|
/// JSON array of feed ids, of those in `feeds`.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub priority: String,
|
|
pub only_unplayed: bool,
|
|
pub oldest_first: bool,
|
|
pub created: i64,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// Words someone never wants to see: an item whose title or text has one is hidden from them and
|
|
/// not downloaded on their account (issue #47). `feed_id` is empty for the list that applies to
|
|
/// every feed they read.
|
|
pub mod blocklists {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "blocklists")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
/// JSON array of strings.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub words: String,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// The items someone's block lists hide from them, worked out whenever a list or the feed
|
|
/// changes (`Db::rehide`), since SQL on both databases cannot match whole words itself.
|
|
pub mod hidden {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "hidden")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub guid: String,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// A feed someone makes from their own subscriptions (#254): the items Jev says fit its
|
|
/// keywords, whichever feed they came from.
|
|
pub mod signals {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "signals")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub name: String,
|
|
/// JSON array of strings.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub keywords: String,
|
|
/// What its owner means by it, in a sentence of their own, when the name and the words
|
|
/// are not enough (#259).
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub description: Option<String>,
|
|
/// Its icon, a Font Awesome Free one as `style/name` (`solid/robot`), in place of its
|
|
/// initials (#261).
|
|
#[sea_orm(column_type = "Text", nullable)]
|
|
pub icon: Option<String>,
|
|
pub created: i64,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// What Jev said of each item a Signal has been asked about, fitting or not: an item with no row
|
|
/// here is still to be asked.
|
|
pub mod signal_verdicts {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "signal_verdicts")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub signal_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub guid: String,
|
|
pub hit: bool,
|
|
/// A picked-out item to ask about again, since its Signal changed (#276). It stays in the
|
|
/// Signal's list until Jev has answered the new question.
|
|
#[sea_orm(default_value = false)]
|
|
pub recheck: bool,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::signals::Entity",
|
|
from = "Column::SignalId",
|
|
to = "super::signals::Column::Id",
|
|
on_delete = "Cascade"
|
|
)]
|
|
Signal,
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
pub mod sessions {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "sessions")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub token: String,
|
|
pub user_id: i64,
|
|
pub seen: i64,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// A phone with the iOS app, signed in as someone, to send the icon's unread count to (#433).
|
|
pub mod push_devices {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "push_devices")]
|
|
pub struct Model {
|
|
/// The token Apple gave the app on that phone, in hex.
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub token: String,
|
|
pub user_id: i64,
|
|
/// From a debug build, which Apple's sandbox serves rather than production.
|
|
pub sandbox: bool,
|
|
pub created: i64,
|
|
/// The count last sent, so a minute in which it did not change sends nothing.
|
|
pub badge: Option<i64>,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// A token a script or agent sends as `Authorization: Bearer`, acting as the person who made
|
|
/// it (#123). Kept as its SHA-256, so the table is no use to anyone who reads it.
|
|
pub mod api_tokens {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "api_tokens")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
/// What its owner called it, to tell one from another when revoking.
|
|
#[sea_orm(column_type = "Text")]
|
|
pub name: String,
|
|
#[sea_orm(unique, column_type = "Text")]
|
|
pub hash: String,
|
|
pub created: i64,
|
|
pub last_used: Option<i64>,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// The catalogue: every feed configured, with its shared settings as `config::Feed` in JSON, so a
|
|
/// new setting on a feed needs no new column. It was config.toml's `[feeds]` (issue #18).
|
|
pub mod catalogue {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "catalogue")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub id: String,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub spec: String,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
/// The server's settings, by name, each a JSON value. `general` is `config::Stored`: what was in
|
|
/// config.toml's `[general]` and the admin page edits. Its row being there is what says the
|
|
/// configuration has moved in (issue #18).
|
|
pub mod settings {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "settings")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub name: String,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub value: String,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
/// What DeadAir found in an enclosure (#181): `plans` is a `deadair::Plan` for each pause length,
|
|
/// as JSON keyed by the pause in ms, and `{}` for a file it does not apply to (video, not MP3 or
|
|
/// AAC, nothing to cut), so that one is looked at once and not every pass.
|
|
pub mod deadair_plans {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "deadair_plans")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub enclosure_id: i64,
|
|
#[sea_orm(column_type = "Text")]
|
|
pub plans: String,
|
|
/// Against the enclosure's `downloaded_at`: a file downloaded again is looked at again.
|
|
pub made_at: i64,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
}
|
|
|
|
/// Who has DeadAir on, for which feeds: it is off for every feed until someone turns it on for
|
|
/// that one or its group, and `wanted` false keeps one feed of a group out of the group's.
|
|
pub mod deadair_prefs {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "deadair_prefs")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
pub wanted: bool,
|
|
/// The pause DeadAir leaves where it cuts a silence, in ms (#182); NULL for the usual.
|
|
pub pause_ms: Option<i64>,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|
|
|
|
/// The time DeadAir has saved someone: one row per episode they got 75% through on a copy, so
|
|
/// replaying it never counts twice. Their total is the sum.
|
|
pub mod deadair_saved {
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "deadair_saved")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub user_id: i64,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub feed_id: String,
|
|
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
|
|
pub guid: String,
|
|
pub saved_ms: i64,
|
|
pub at: i64,
|
|
}
|
|
|
|
owned_by_user!();
|
|
}
|