| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
use crate::db::ListKind; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 34 |
pub enum EmailClass { |
| 35 |
|
| 36 |
|
| 37 |
Operational(OperationalKind), |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
Optional(ListKind), |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
ListAudience, |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
#[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 63 |
pub enum OperationalKind { |
| 64 |
PasswordReset, |
| 65 |
EmailVerification, |
| 66 |
LoginLink, |
| 67 |
AccountLockout, |
| 68 |
AccountExists, |
| 69 |
DeletionConfirmation, |
| 70 |
PolicyWarning, |
| 71 |
Suspension, |
| 72 |
AppealDecision, |
| 73 |
ContentRemoval, |
| 74 |
ContentRestored, |
| 75 |
AccountTermination, |
| 76 |
PlatformShutdown, |
| 77 |
PurchaseReceipt, |
| 78 |
SubscriptionBilling, |
| 79 |
FanPlus, |
| 80 |
ContentExport, |
| 81 |
CreatorDeparture, |
| 82 |
UsageLimit, |
| 83 |
AcknowledgementRequired, |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
OperatorAlert, |
| 89 |
} |
| 90 |
|
| 91 |
impl OperationalKind { |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
pub const ALL: &'static [OperationalKind] = &[ |
| 97 |
OperationalKind::PasswordReset, |
| 98 |
OperationalKind::EmailVerification, |
| 99 |
OperationalKind::LoginLink, |
| 100 |
OperationalKind::AccountLockout, |
| 101 |
OperationalKind::AccountExists, |
| 102 |
OperationalKind::DeletionConfirmation, |
| 103 |
OperationalKind::PolicyWarning, |
| 104 |
OperationalKind::Suspension, |
| 105 |
OperationalKind::AppealDecision, |
| 106 |
OperationalKind::ContentRemoval, |
| 107 |
OperationalKind::ContentRestored, |
| 108 |
OperationalKind::AccountTermination, |
| 109 |
OperationalKind::PlatformShutdown, |
| 110 |
OperationalKind::PurchaseReceipt, |
| 111 |
OperationalKind::SubscriptionBilling, |
| 112 |
OperationalKind::FanPlus, |
| 113 |
OperationalKind::ContentExport, |
| 114 |
OperationalKind::CreatorDeparture, |
| 115 |
OperationalKind::UsageLimit, |
| 116 |
OperationalKind::AcknowledgementRequired, |
| 117 |
OperationalKind::OperatorAlert, |
| 118 |
]; |
| 119 |
|
| 120 |
|
| 121 |
pub fn label(self) -> &'static str { |
| 122 |
match self { |
| 123 |
Self::PasswordReset => "Password reset", |
| 124 |
Self::EmailVerification => "Email verification", |
| 125 |
Self::LoginLink => "Login link", |
| 126 |
Self::AccountLockout => "Account lockout", |
| 127 |
Self::AccountExists => "Account already exists", |
| 128 |
Self::DeletionConfirmation => "Account deletion confirmation", |
| 129 |
Self::PolicyWarning => "Policy notice", |
| 130 |
Self::Suspension => "Account suspension", |
| 131 |
Self::AppealDecision => "Appeal decision", |
| 132 |
Self::ContentRemoval => "Content removed", |
| 133 |
Self::ContentRestored => "Content restored", |
| 134 |
Self::AccountTermination => "Account termination", |
| 135 |
Self::PlatformShutdown => "Platform shutdown notice", |
| 136 |
Self::PurchaseReceipt => "Purchase receipt", |
| 137 |
Self::SubscriptionBilling => "Subscription billing", |
| 138 |
Self::FanPlus => "Fan+ membership and credits", |
| 139 |
Self::ContentExport => "Content export", |
| 140 |
Self::CreatorDeparture => "A creator you bought from is leaving", |
| 141 |
Self::UsageLimit => "Usage limit warning", |
| 142 |
Self::AcknowledgementRequired => "Something needs your confirmation", |
| 143 |
Self::OperatorAlert => "Operator alert", |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
pub fn user_facing(self) -> bool { |
| 154 |
!matches!(self, Self::OperatorAlert) |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
pub fn justification(self) -> &'static str { |
| 162 |
match self { |
| 163 |
Self::PasswordReset => { |
| 164 |
"You asked to reset your password, and the link is the only way to finish." |
| 165 |
} |
| 166 |
Self::EmailVerification => { |
| 167 |
"Verifying the address is how we know mail to it reaches you." |
| 168 |
} |
| 169 |
Self::LoginLink => "You asked for a link to sign in, and this message carries it.", |
| 170 |
Self::AccountLockout => { |
| 171 |
"Your account was locked after failed sign-ins, which is worth knowing about \ |
| 172 |
whether or not it was you." |
| 173 |
} |
| 174 |
Self::AccountExists => { |
| 175 |
"Someone tried to sign up with your address. Only you receive this, and it is \ |
| 176 |
how you recover an account you had forgotten." |
| 177 |
} |
| 178 |
Self::DeletionConfirmation => { |
| 179 |
"Deleting an account is permanent, so it is confirmed by a link only the \ |
| 180 |
address owner receives." |
| 181 |
} |
| 182 |
Self::PolicyWarning => { |
| 183 |
"A problem with your account or content, sent before anything is acted on so \ |
| 184 |
you have the chance to address it." |
| 185 |
} |
| 186 |
Self::Suspension => { |
| 187 |
"Your account has been suspended. You cannot appeal a decision you were never \ |
| 188 |
told about." |
| 189 |
} |
| 190 |
Self::AppealDecision => "The outcome of an appeal you submitted.", |
| 191 |
Self::ContentRemoval => { |
| 192 |
"Something you published is no longer publicly reachable, and you would \ |
| 193 |
otherwise find out by accident." |
| 194 |
} |
| 195 |
Self::ContentRestored => "Something of yours that had been removed is back.", |
| 196 |
Self::AccountTermination => { |
| 197 |
"Your account is being closed and you have a limited window to export your \ |
| 198 |
data." |
| 199 |
} |
| 200 |
Self::PlatformShutdown => { |
| 201 |
"Makenotwork is shutting down and you have a limited window to take your work \ |
| 202 |
elsewhere. No-lock-in is meaningless if the notice is optional." |
| 203 |
} |
| 204 |
Self::PurchaseReceipt => { |
| 205 |
"A record of money you spent, and for a guest purchase the download link \ |
| 206 |
itself." |
| 207 |
} |
| 208 |
Self::SubscriptionBilling => { |
| 209 |
"A recurring charge starting, renewing, or ending. You are entitled to know \ |
| 210 |
what you are being billed." |
| 211 |
} |
| 212 |
Self::FanPlus => { |
| 213 |
"Your Fan+ membership status and the monthly credit code, which has no other \ |
| 214 |
delivery route." |
| 215 |
} |
| 216 |
Self::ContentExport => { |
| 217 |
"The export you requested is ready, or failed. The download link expires, and \ |
| 218 |
a failed job would otherwise leave you waiting." |
| 219 |
} |
| 220 |
Self::CreatorDeparture => { |
| 221 |
"A creator you bought from has left, and what you purchased stays available \ |
| 222 |
for a limited time. Sent by the platform, not the creator." |
| 223 |
} |
| 224 |
Self::UsageLimit => { |
| 225 |
"You are approaching or have reached a plan limit. Past it, requests are \ |
| 226 |
refused, so a silent limit would read as an outage." |
| 227 |
} |
| 228 |
Self::AcknowledgementRequired => { |
| 229 |
"Something changed that only you can act on, and it repeats until you \ |
| 230 |
confirm you have seen it. Confirming is what stops it." |
| 231 |
} |
| 232 |
Self::OperatorAlert => { |
| 233 |
"Sent to a Makenotwork operations address, not to a user account." |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
pub fn operational_mail_doc() -> String { |
| 247 |
let mut s = String::from( |
| 248 |
"# Email you cannot turn off\n\ |
| 249 |
\n\ |
| 250 |
Most of our email is optional. You can turn it off in Dashboard, Account,\n\ |
| 251 |
Notification Preferences, and we will not send it again.\n\ |
| 252 |
\n\ |
| 253 |
The messages below are the exception. Each one carries something you\n\ |
| 254 |
cannot act on if it never arrives: a link only you receive, a record of\n\ |
| 255 |
money that moved, or notice of something happening to your account. They\n\ |
| 256 |
are sent whatever your preferences say, and this page is the complete\n\ |
| 257 |
list.\n\ |
| 258 |
\n\ |
| 259 |
This page is generated from the code that sends the mail, so it cannot\n\ |
| 260 |
drift from what actually happens.\n\ |
| 261 |
\n", |
| 262 |
); |
| 263 |
for kind in OperationalKind::ALL.iter().filter(|k| k.user_facing()) { |
| 264 |
use std::fmt::Write as _; |
| 265 |
let _ = write!(s, "## {}\n\n{}\n\n", kind.label(), kind.justification()); |
| 266 |
} |
| 267 |
s.push_str( |
| 268 |
"## Everything else\n\ |
| 269 |
\n\ |
| 270 |
Sales, tips, followers, new-device sign-ins, issue activity, platform\n\ |
| 271 |
status, release and blog announcements, and onboarding tips are all\n\ |
| 272 |
optional. Announcements from a creator you follow are governed by the\n\ |
| 273 |
mailing list you subscribed to, and every one of them carries a\n\ |
| 274 |
one-click unsubscribe link.\n", |
| 275 |
); |
| 276 |
s |
| 277 |
} |
| 278 |
|
| 279 |
#[cfg(test)] |
| 280 |
mod tests { |
| 281 |
use super::*; |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
#[test] |
| 290 |
fn operational_set_is_closed() { |
| 291 |
let actual: Vec<&str> = OperationalKind::ALL.iter().map(|k| k.label()).collect(); |
| 292 |
let expected = [ |
| 293 |
"Password reset", |
| 294 |
"Email verification", |
| 295 |
"Login link", |
| 296 |
"Account lockout", |
| 297 |
"Account already exists", |
| 298 |
"Account deletion confirmation", |
| 299 |
"Policy notice", |
| 300 |
"Account suspension", |
| 301 |
"Appeal decision", |
| 302 |
"Content removed", |
| 303 |
"Content restored", |
| 304 |
"Account termination", |
| 305 |
"Platform shutdown notice", |
| 306 |
"Purchase receipt", |
| 307 |
"Subscription billing", |
| 308 |
"Fan+ membership and credits", |
| 309 |
"Content export", |
| 310 |
"A creator you bought from is leaving", |
| 311 |
"Usage limit warning", |
| 312 |
"Something needs your confirmation", |
| 313 |
"Operator alert", |
| 314 |
]; |
| 315 |
assert_eq!( |
| 316 |
actual, expected, |
| 317 |
"the set of emails a user cannot opt out of changed. That is a promise to users, \ |
| 318 |
not an implementation detail: confirm the new one genuinely cannot be optional, \ |
| 319 |
write its justification copy, then update this expected list." |
| 320 |
); |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
#[test] |
| 328 |
fn all_is_exhaustive() { |
| 329 |
|
| 330 |
|
| 331 |
for k in OperationalKind::ALL { |
| 332 |
let _: &str = match k { |
| 333 |
OperationalKind::PasswordReset |
| 334 |
| OperationalKind::EmailVerification |
| 335 |
| OperationalKind::LoginLink |
| 336 |
| OperationalKind::AccountLockout |
| 337 |
| OperationalKind::AccountExists |
| 338 |
| OperationalKind::DeletionConfirmation |
| 339 |
| OperationalKind::PolicyWarning |
| 340 |
| OperationalKind::Suspension |
| 341 |
| OperationalKind::AppealDecision |
| 342 |
| OperationalKind::ContentRemoval |
| 343 |
| OperationalKind::ContentRestored |
| 344 |
| OperationalKind::AccountTermination |
| 345 |
| OperationalKind::PlatformShutdown |
| 346 |
| OperationalKind::PurchaseReceipt |
| 347 |
| OperationalKind::SubscriptionBilling |
| 348 |
| OperationalKind::FanPlus |
| 349 |
| OperationalKind::ContentExport |
| 350 |
| OperationalKind::CreatorDeparture |
| 351 |
| OperationalKind::UsageLimit |
| 352 |
| OperationalKind::AcknowledgementRequired |
| 353 |
| OperationalKind::OperatorAlert => k.justification(), |
| 354 |
}; |
| 355 |
} |
| 356 |
assert_eq!(OperationalKind::ALL.len(), 21); |
| 357 |
} |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
#[test] |
| 366 |
fn committed_doc_matches_generated() { |
| 367 |
const DOC: &str = concat!( |
| 368 |
env!("CARGO_MANIFEST_DIR"), |
| 369 |
"/site-docs/public/guide/email-you-cannot-turn-off.md" |
| 370 |
); |
| 371 |
let committed = std::fs::read_to_string(DOC).expect("the guide page is committed"); |
| 372 |
assert_eq!( |
| 373 |
committed, |
| 374 |
operational_mail_doc(), |
| 375 |
"site-docs/public/guide/email-you-cannot-turn-off.md is stale. Regenerate it with \ |
| 376 |
`cargo run --bin export-operational-mail-doc`." |
| 377 |
); |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
#[test] |
| 383 |
fn justifications_are_sentences() { |
| 384 |
for k in OperationalKind::ALL { |
| 385 |
let j = k.justification(); |
| 386 |
assert!( |
| 387 |
j.ends_with('.'), |
| 388 |
"{}: justification should be a sentence", |
| 389 |
k.label() |
| 390 |
); |
| 391 |
assert!( |
| 392 |
!j.contains('\u{2014}') && !j.contains(" -- "), |
| 393 |
"{}: no connective dashes in user-facing copy", |
| 394 |
k.label() |
| 395 |
); |
| 396 |
assert!( |
| 397 |
!j.contains(" "), |
| 398 |
"{}: double space in justification", |
| 399 |
k.label() |
| 400 |
); |
| 401 |
} |
| 402 |
} |
| 403 |
} |
| 404 |
|