Skip to main content

spoolframe_protocol/federation/
subtitles.rs

1//! Subtitle search on a paired server's item: the user's home server
2//! passes `SearchSubtitles`, `DownloadSubtitle` and
3//! `RemoveSubtitleDownload` of a `fed:` item to the item's server (the
4//! server whose item it is). That server plans the play and burns
5//! subtitles in, so the file must be there.
6//!
7//! The item's server searches with its own sites and ranking, ordered by
8//! the user's own SDH and forced choices on the home server, and keeps
9//! what it downloads as its own, for everyone. All the home server's users
10//! together get one daily allowance on the item's server
11//! (`subtitles { daily_limit_per_peer }`). It is counted under the pair,
12//! never under the home server's users, whom the item's server never
13//! names. The home server holds each of its users to its own per-user
14//! limit first.
15//!
16//! Each ask arrives on the pair's connection, which proves who sends it,
17//! as an assertion does: the user is the home server's local account, by
18//! its stable id.
19
20use serde::{Deserialize, Serialize};
21use spoolframe_types::SubtitlePreferences;
22
23/// `SearchSubtitles` of the item's server's `item` for the home server's
24/// `user`: answered with `SubtitleResults`, or `Failed`.
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct SubtitleSearchAsk {
27    /// The user's stable id on the home server, as an assertion names
28    /// them.
29    pub user: String,
30    /// Their subtitle choices on the home server: what the results are
31    /// ordered by.
32    #[serde(default)]
33    pub subtitles: SubtitlePreferences,
34    /// The item, by the item's server's own id.
35    pub item: String,
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub language: Option<String>,
38}
39
40/// `DownloadSubtitle` of result `result` of a search for the item's
41/// server's `item`, for the home server's `user`: answered with
42/// `SubtitleDownloaded`, or `Failed`.
43#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
44pub struct SubtitleDownloadAsk {
45    pub user: String,
46    pub item: String,
47    pub result: String,
48}
49
50/// `RemoveSubtitleDownload` of download `download` of the item's server's
51/// `item`, for the home server's `user`: answered with `Done`, or
52/// `Failed`.
53#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
54pub struct SubtitleRemovalAsk {
55    pub user: String,
56    pub item: String,
57    pub download: String,
58}