mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-10 18:55:57 +03:00
Start using rustfmt and some style changes to make some lines shorter
This commit is contained in:
45
src/mail.rs
45
src/mail.rs
@@ -1,8 +1,8 @@
|
||||
use native_tls::{Protocol, TlsConnector};
|
||||
use lettre::{Transport, SmtpTransport, SmtpClient, ClientTlsParameters, ClientSecurity};
|
||||
use lettre::smtp::ConnectionReuseParameters;
|
||||
use lettre::smtp::authentication::Credentials;
|
||||
use lettre::smtp::ConnectionReuseParameters;
|
||||
use lettre::{ClientSecurity, ClientTlsParameters, SmtpClient, SmtpTransport, Transport};
|
||||
use lettre_email::EmailBuilder;
|
||||
use native_tls::{Protocol, TlsConnector};
|
||||
|
||||
use crate::MailConfig;
|
||||
use crate::CONFIG;
|
||||
@@ -22,10 +22,7 @@ fn mailer(config: &MailConfig) -> SmtpTransport {
|
||||
ClientSecurity::None
|
||||
};
|
||||
|
||||
let smtp_client = SmtpClient::new(
|
||||
(config.smtp_host.as_str(), config.smtp_port),
|
||||
client_security,
|
||||
).unwrap();
|
||||
let smtp_client = SmtpClient::new((config.smtp_host.as_str(), config.smtp_port), client_security).unwrap();
|
||||
|
||||
let smtp_client = match (&config.smtp_username, &config.smtp_password) {
|
||||
(Some(user), Some(pass)) => smtp_client.credentials(Credentials::new(user.clone(), pass.clone())),
|
||||
@@ -40,15 +37,20 @@ fn mailer(config: &MailConfig) -> SmtpTransport {
|
||||
|
||||
pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConfig) -> EmptyResult {
|
||||
let (subject, body) = if let Some(hint) = hint {
|
||||
("Your master password hint",
|
||||
format!(
|
||||
"You (or someone) recently requested your master password hint.\n\n\
|
||||
Your hint is: \"{}\"\n\n\
|
||||
If you did not request your master password hint you can safely ignore this email.\n",
|
||||
hint))
|
||||
(
|
||||
"Your master password hint",
|
||||
format!(
|
||||
"You (or someone) recently requested your master password hint.\n\n\
|
||||
Your hint is: \"{}\"\n\n\
|
||||
If you did not request your master password hint you can safely ignore this email.\n",
|
||||
hint
|
||||
),
|
||||
)
|
||||
} else {
|
||||
("Sorry, you have no password hint...",
|
||||
"Sorry, you have not specified any password hint...\n".into())
|
||||
(
|
||||
"Sorry, you have no password hint...",
|
||||
"Sorry, you have not specified any password hint...\n".into(),
|
||||
)
|
||||
};
|
||||
|
||||
let email = EmailBuilder::new()
|
||||
@@ -65,8 +67,15 @@ pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConf
|
||||
.and(Ok(()))
|
||||
}
|
||||
|
||||
pub fn send_invite(address: &str, org_id: &str, org_user_id: &str, token: &str, org_name: &str, config: &MailConfig) -> EmptyResult {
|
||||
let (subject, body) = {
|
||||
pub fn send_invite(
|
||||
address: &str,
|
||||
org_id: &str,
|
||||
org_user_id: &str,
|
||||
token: &str,
|
||||
org_name: &str,
|
||||
config: &MailConfig,
|
||||
) -> EmptyResult {
|
||||
let (subject, body) = {
|
||||
(format!("Join {}", &org_name),
|
||||
format!(
|
||||
"<html>
|
||||
@@ -91,4 +100,4 @@ pub fn send_invite(address: &str, org_id: &str, org_user_id: &str, token: &str,
|
||||
.send(email.into())
|
||||
.map_err(|e| Error::new("Error sending invite email", e.to_string()))
|
||||
.and(Ok(()))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user