-
Notifications
You must be signed in to change notification settings - Fork 684
Closed
Labels
A-backend ⚙️C-internal 🔧Category: Nonessential work that would make the codebase more consistent or clearCategory: Nonessential work that would make the codebase more consistent or clear
Description
We had some reports that email verification emails weren't arriving. Our best suspicion of the cause is that somehow an environment variable wasn't set (there weren't any config changes logged on the server, so we're not sure how that could have happened).
We should always have email configured in production, so this code:
Lines 17 to 36 in dd9893b
| /// Create a new instance detecting the backend from the environment. This will either connect | |
| /// to a SMTP server or store the emails on the local filesystem. | |
| pub fn from_environment() -> Self { | |
| let backend = match ( | |
| dotenv::var("MAILGUN_SMTP_LOGIN"), | |
| dotenv::var("MAILGUN_SMTP_PASSWORD"), | |
| dotenv::var("MAILGUN_SMTP_SERVER"), | |
| ) { | |
| (Ok(login), Ok(password), Ok(server)) => EmailBackend::Smtp { | |
| server, | |
| login, | |
| password, | |
| }, | |
| _ => EmailBackend::FileSystem { | |
| path: "/tmp".into(), | |
| }, | |
| }; | |
| Self { backend } | |
| } |
should never fall back to EmailBackend::FileSystem in production, it should panic. The Env enum can be used for this:
Lines 60 to 71 in dd9893b
| /// Used for setting different values depending on whether the app is being run in production, | |
| /// in development, or for testing. | |
| /// | |
| /// The app's `config.env` value is set in *src/bin/server.rs* to `Production` if the environment | |
| /// variable `HEROKU` is set and `Development` otherwise. `config.env` is set to `Test` | |
| /// unconditionally in *src/test/all.rs*. | |
| #[derive(PartialEq, Eq, Clone, Copy, Debug)] | |
| pub enum Env { | |
| Development, | |
| Test, | |
| Production, | |
| } |
cc @rust-lang/crates-io-on-call, this would be super helpful for production support.
Metadata
Metadata
Assignees
Labels
A-backend ⚙️C-internal 🔧Category: Nonessential work that would make the codebase more consistent or clearCategory: Nonessential work that would make the codebase more consistent or clear