From 97aa407fe4eadb00f048f1700154359cecfe5a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Sat, 19 Jan 2019 16:52:12 +0100 Subject: [PATCH] Move email templates to subfolder --- src/mail.rs | 10 +++++----- src/main.rs | 10 +++++----- .../invite_accepted.hbs} | 0 .../invite_confirmed.hbs} | 0 .../{email_pw_hint_none.hbs => email/pw_hint_none.hbs} | 0 .../{email_pw_hint_some.hbs => email/pw_hint_some.hbs} | 0 .../send_org_invite.hbs} | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename src/static/templates/{email_invite_accepted.hbs => email/invite_accepted.hbs} (100%) rename src/static/templates/{email_invite_confirmed.hbs => email/invite_confirmed.hbs} (100%) rename src/static/templates/{email_pw_hint_none.hbs => email/pw_hint_none.hbs} (100%) rename src/static/templates/{email_pw_hint_some.hbs => email/pw_hint_some.hbs} (100%) rename src/static/templates/{email_send_org_invite.hbs => email/send_org_invite.hbs} (100%) diff --git a/src/mail.rs b/src/mail.rs index 5e245b4b..6eddcc19 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -54,9 +54,9 @@ fn get_text(template_name: &'static str, data: serde_json::Value) -> Result<(Str pub fn send_password_hint(address: &str, hint: Option, config: &MailConfig) -> EmptyResult { let template_name = if hint.is_some() { - "email_pw_hint_some" + "email/pw_hint_some" } else { - "email_pw_hint_none" + "email/pw_hint_none" }; let (subject, body) = get_text(template_name, json!({ "hint": hint }))?; @@ -83,7 +83,7 @@ pub fn send_invite( let invite_token = encode_jwt(&claims); let (subject, body) = get_text( - "email_send_org_invite", + "email/send_org_invite", json!({ "url": CONFIG.domain, "org_id": org_id.unwrap_or("_".to_string()), @@ -99,7 +99,7 @@ pub fn send_invite( pub fn send_invite_accepted(new_user_email: &str, address: &str, org_name: &str, config: &MailConfig) -> EmptyResult { let (subject, body) = get_text( - "email_invite_accepted", + "email/invite_accepted", json!({ "url": CONFIG.domain, "email": new_user_email, @@ -112,7 +112,7 @@ pub fn send_invite_accepted(new_user_email: &str, address: &str, org_name: &str, pub fn send_invite_confirmed(address: &str, org_name: &str, config: &MailConfig) -> EmptyResult { let (subject, body) = get_text( - "email_invite_confirmed", + "email/invite_confirmed", json!({ "url": CONFIG.domain, "org_name": org_name, diff --git a/src/main.rs b/src/main.rs index 619558ee..88b0d402 100644 --- a/src/main.rs +++ b/src/main.rs @@ -345,11 +345,11 @@ fn load_templates(path: String) -> Handlebars { } // First register default templates here (use include_str?) - reg!("email_invite_accepted"); - reg!("email_invite_confirmed"); - reg!("email_pw_hint_none"); - reg!("email_pw_hint_some"); - reg!("email_send_org_invite"); + reg!("email/invite_accepted"); + reg!("email/invite_confirmed"); + reg!("email/pw_hint_none"); + reg!("email/pw_hint_some"); + reg!("email/send_org_invite"); // And then load user templates to overwrite the defaults // Use .hbs extension for the files diff --git a/src/static/templates/email_invite_accepted.hbs b/src/static/templates/email/invite_accepted.hbs similarity index 100% rename from src/static/templates/email_invite_accepted.hbs rename to src/static/templates/email/invite_accepted.hbs diff --git a/src/static/templates/email_invite_confirmed.hbs b/src/static/templates/email/invite_confirmed.hbs similarity index 100% rename from src/static/templates/email_invite_confirmed.hbs rename to src/static/templates/email/invite_confirmed.hbs diff --git a/src/static/templates/email_pw_hint_none.hbs b/src/static/templates/email/pw_hint_none.hbs similarity index 100% rename from src/static/templates/email_pw_hint_none.hbs rename to src/static/templates/email/pw_hint_none.hbs diff --git a/src/static/templates/email_pw_hint_some.hbs b/src/static/templates/email/pw_hint_some.hbs similarity index 100% rename from src/static/templates/email_pw_hint_some.hbs rename to src/static/templates/email/pw_hint_some.hbs diff --git a/src/static/templates/email_send_org_invite.hbs b/src/static/templates/email/send_org_invite.hbs similarity index 100% rename from src/static/templates/email_send_org_invite.hbs rename to src/static/templates/email/send_org_invite.hbs