parent
abcaa95627
commit
2ee7526171
20
src/mail.rs
20
src/mail.rs
|
@ -57,14 +57,15 @@ impl Service {
|
|||
};
|
||||
|
||||
self.send(
|
||||
userid,
|
||||
&vec![userid.clone()],
|
||||
"Please verify your email address",
|
||||
"verify",
|
||||
ctx,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn send_confirmation(&self, userid: &Email, token: &str, domain: &str)
|
||||
pub fn send_confirmation(&self, userids: &[Email], token: &str,
|
||||
domain: &str)
|
||||
-> Result<()> {
|
||||
let ctx = Context {
|
||||
token: token.to_string(),
|
||||
|
@ -73,14 +74,14 @@ impl Service {
|
|||
};
|
||||
|
||||
self.send(
|
||||
userid,
|
||||
userids,
|
||||
"Please confirm deletion of your key",
|
||||
"confirm",
|
||||
ctx,
|
||||
)
|
||||
}
|
||||
|
||||
fn send<T>(&self, to: &Email, subject: &str, template: &str, ctx: T)
|
||||
fn send<T>(&self, to: &[Email], subject: &str, template: &str, ctx: T)
|
||||
-> Result<()>
|
||||
where T: Serialize + Clone,
|
||||
{
|
||||
|
@ -97,14 +98,19 @@ impl Service {
|
|||
}
|
||||
};
|
||||
|
||||
let email = EmailBuilder::new()
|
||||
.to(to.to_string())
|
||||
let mut email = EmailBuilder::new()
|
||||
.from(self.from.clone())
|
||||
.subject(subject)
|
||||
.alternative(
|
||||
html.ok_or(failure::err_msg("Email template failed to render"))?,
|
||||
txt.ok_or(failure::err_msg("Email template failed to render"))?,
|
||||
)
|
||||
);
|
||||
|
||||
for recipient in to.iter() {
|
||||
email.add_to(recipient.to_string());
|
||||
}
|
||||
|
||||
let email = email
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -498,11 +498,9 @@ fn manage_post(
|
|||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
for uid in uids {
|
||||
if let Err(e) = mail_service.send_confirmation(
|
||||
&uid, &token, &domain.0) {
|
||||
return MyResponse::ise(e);
|
||||
}
|
||||
if let Err(e) = mail_service.send_confirmation(
|
||||
&uids, &token, &domain.0) {
|
||||
return MyResponse::ise(e);
|
||||
}
|
||||
|
||||
MyResponse::ok("delete", context)
|
||||
|
|
Loading…
Reference in New Issue