| 66 |
66 |
|
pub everything_total_bytes: i64,
|
| 67 |
67 |
|
// Founder cohort cap, display string with thousands separator ("1,000").
|
| 68 |
68 |
|
pub cohort_cap_display: String,
|
|
69 |
+ |
// Monthly mail allowance per tier, and the allowance for a creator with no
|
|
70 |
+ |
// active subscription. See `crate::db::mail_caps`; the numbers are
|
|
71 |
+ |
// provisional pending the pricing call.
|
|
72 |
+ |
pub basic_mail_cap: i64,
|
|
73 |
+ |
pub small_files_mail_cap: i64,
|
|
74 |
+ |
pub big_files_mail_cap: i64,
|
|
75 |
+ |
pub everything_mail_cap: i64,
|
|
76 |
+ |
pub no_subscription_mail_cap: i64,
|
|
77 |
+ |
// Where the warning band starts, as a fraction of the effective cap.
|
|
78 |
+ |
pub mail_cap_warn_at: f64,
|
| 69 |
79 |
|
}
|
| 70 |
80 |
|
|
| 71 |
81 |
|
impl TierPrices {
|
| 104 |
114 |
|
big_files_total_bytes: bytes_at(a, "tier_bytes.big_files_total"),
|
| 105 |
115 |
|
everything_total_bytes: bytes_at(a, "tier_bytes.everything_total"),
|
| 106 |
116 |
|
cohort_cap_display: str_at(a, "cohort.cap_display"),
|
|
117 |
+ |
basic_mail_cap: bytes_at(a, "mail_cap.basic"),
|
|
118 |
+ |
small_files_mail_cap: bytes_at(a, "mail_cap.small_files"),
|
|
119 |
+ |
big_files_mail_cap: bytes_at(a, "mail_cap.big_files"),
|
|
120 |
+ |
everything_mail_cap: bytes_at(a, "mail_cap.everything"),
|
|
121 |
+ |
no_subscription_mail_cap: bytes_at(a, "mail_cap.no_subscription"),
|
|
122 |
+ |
mail_cap_warn_at: float_at(a, "mail_cap.warn_at_fraction"),
|
| 107 |
123 |
|
}
|
| 108 |
124 |
|
}
|
| 109 |
125 |
|
|
| 129 |
145 |
|
}
|
| 130 |
146 |
|
}
|
| 131 |
147 |
|
|
|
148 |
+ |
/// Monthly mail allowance for the given tier, before any per-account
|
|
149 |
+ |
/// override. `None` is a creator with no active subscription, who still
|
|
150 |
+ |
/// sends and gets the smaller unsubscribed allowance.
|
|
151 |
+ |
pub fn monthly_mail_cap_for(&self, tier: Option<CreatorTier>) -> i64 {
|
|
152 |
+ |
match tier {
|
|
153 |
+ |
None => self.no_subscription_mail_cap,
|
|
154 |
+ |
Some(CreatorTier::Basic) => self.basic_mail_cap,
|
|
155 |
+ |
Some(CreatorTier::SmallFiles) => self.small_files_mail_cap,
|
|
156 |
+ |
Some(CreatorTier::BigFiles) => self.big_files_mail_cap,
|
|
157 |
+ |
Some(CreatorTier::Everything) => self.everything_mail_cap,
|
|
158 |
+ |
}
|
|
159 |
+ |
}
|
|
160 |
+ |
|
| 132 |
161 |
|
/// Total storage byte cap for the given tier.
|
| 133 |
162 |
|
pub fn max_storage_bytes_for(&self, tier: CreatorTier) -> i64 {
|
| 134 |
163 |
|
match tier {
|
| 302 |
331 |
|
}
|
| 303 |
332 |
|
}
|
| 304 |
333 |
|
|
|
334 |
+ |
fn float_at(a: &Assumptions, key: &str) -> f64 {
|
|
335 |
+ |
match a.get(key) {
|
|
336 |
+ |
Some(LookupValue::Float(x)) => *x,
|
|
337 |
+ |
// A ratio written as `1` rather than `1.0` is still a ratio.
|
|
338 |
+ |
Some(LookupValue::Int(n)) => *n as f64,
|
|
339 |
+ |
other => panic!("expected number at {key}, got {other:?}"),
|
|
340 |
+ |
}
|
|
341 |
+ |
}
|
|
342 |
+ |
|
| 305 |
343 |
|
fn str_at(a: &Assumptions, key: &str) -> String {
|
| 306 |
344 |
|
match a.get(key) {
|
| 307 |
345 |
|
Some(LookupValue::String(s)) => s.clone(),
|