use super::auth::human;
use ryuk::mail::{Mail, MailError, Template};
use std::time::Duration;
#[derive(Template)]
#[template(path = "mail/org_invitation.html", askama = ryuk::mail::askama)]
struct InvitationHtml<'a> {
inviter: &'a str,
org: &'a str,
role: &'a str,
link: &'a str,
life: &'a str,
}
#[derive(Template)]
#[template(path = "mail/org_invitation.txt", askama = ryuk::mail::askama)]
struct InvitationText<'a> {
inviter: &'a str,
org: &'a str,
role: &'a str,
link: &'a str,
life: &'a str,
}
pub fn invitation(inviter: &str, org: &str, role: &str, to: &str, link: &str, ttl: Duration) -> Result<Mail, MailError> {
let life = human(ttl);
Mail::new()
.to(to)
.subject("You were invited to an organization")
.text_template(&InvitationText { inviter, org, role, link, life: &life })?
.html_template(&InvitationHtml { inviter, org, role, link, life: &life })
}