0
0
Fork 0
mirror of https://git.verdigado.com/NB-Public/simple-wkd.git synced 2024-12-06 14:52:41 +01:00

Add a webpage

This commit is contained in:
Delta1925 2023-04-15 23:51:13 +02:00
parent e621a735f5
commit a91b213dbf
No known key found for this signature in database
GPG key ID: 1C21ACE44193CB25
9 changed files with 107 additions and 47 deletions

View file

@ -105,6 +105,13 @@ pub fn confirm_action(token: &str) -> Result<(Action, String), Error> {
pub fn send_confirmation_email(address: &str, action: &Action, token: &str) -> Result<(), Error> {
debug!("Sending email to {}", address);
let template = fs::read_to_string(Path::new("assets").join("mail-template.html")).unwrap();
let mut url = SETTINGS
.external_url
.join("api/")
.unwrap()
.join("confirm")
.unwrap();
url.set_query(Some(&format!("token={}", token)));
let email = Message::builder()
.from(match SETTINGS.mail_settings.mail_from.parse() {
Ok(mailbox) => mailbox,
@ -129,18 +136,7 @@ pub fn send_confirmation_email(address: &str, action: &Action, token: &str) -> R
.header(ContentType::TEXT_HTML)
.body(
template
.replace(
"{{%u}}",
SETTINGS
.external_url
.join("api/")
.unwrap()
.join("confirm/")
.unwrap()
.join(token)
.unwrap()
.as_ref(),
)
.replace("{{%u}}", url.as_ref())
.replace("{{%a}}", &action.to_string().to_lowercase()),
);