diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cd9157c..9589f6d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,4 +36,5 @@ jobs: project-id: proj_01JNH9KPMRS34FKC2NHWQ5YNNB secrets: | SMTP_MAIL = '${{ secrets.SMTP_MAIL }}' - SMTP_SECRET = '${{ secrets.SMTP_SECRET }}' \ No newline at end of file + SMTP_SECRET = '${{ secrets.SMTP_SECRET }}' + SMTP_PROVIDER = '${{ secrets.SMTP_PROVIDER }}' \ No newline at end of file diff --git a/src/api/v1/onboarding/registration.rs b/src/api/v1/onboarding/registration.rs index a706bd8..1dd1768 100644 --- a/src/api/v1/onboarding/registration.rs +++ b/src/api/v1/onboarding/registration.rs @@ -47,7 +47,7 @@ pub async fn register( let credentials = Credentials::new(smtp.mail().to_string(), smtp.secret().to_string()); #[allow(clippy::unwrap_used)] - let mailer = SmtpTransport::relay("smtp.gmail.com") + let mailer = SmtpTransport::relay(smtp.provider()) .unwrap() .credentials(credentials) .build(); diff --git a/src/main.rs b/src/main.rs index f9b2a9a..da9b606 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ async fn main(#[shuttle_runtime::Secrets] secrets: SecretStore) -> shuttle_axum: let smtp_config = digitaler_frieden::config::SMTPConfig::new( &secrets.get("SMTP_MAIL").expect("SMTP_MAIL not set"), &secrets.get("SMTP_SECRET").expect("SMTP_SECRET not set"), + &secrets.get("SMTP_PROVIDER").expect("SMTP_PROVIDER not set"), ); let router = digitaler_frieden::new(smtp_config); Ok(router.into()) diff --git a/src/model/config/smtp_config.rs b/src/model/config/smtp_config.rs index 3b47b38..6b7f438 100644 --- a/src/model/config/smtp_config.rs +++ b/src/model/config/smtp_config.rs @@ -5,13 +5,15 @@ use std::fmt::Debug; pub struct SMTPConfig { mail: String, secret: String, + provider: String, } impl SMTPConfig { - pub fn new>(mail: T, secret: T) -> Self { + pub fn new>(mail: T, secret: T, provider: T) -> Self { Self { mail: mail.as_ref().to_owned(), secret: secret.as_ref().to_owned(), + provider: provider.as_ref().to_owned(), } } @@ -24,12 +26,18 @@ impl SMTPConfig { pub fn secret(&self) -> &str { &self.secret } + + #[must_use] + pub fn provider(&self) -> &str { + &self.provider + } } impl Debug for SMTPConfig { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("SMTPConfig") .field("mail", &self.mail) + .field("provider", &self.provider) .field("secret", &"") .finish() }