1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

templates: translate a lot more stuff

This commit is contained in:
Quentin Gliech
2023-10-05 17:20:02 +02:00
parent 6ff549f5df
commit b2cd8d83f7
32 changed files with 385 additions and 97 deletions

View File

@ -32,7 +32,9 @@ serde_json.workspace = true
mas-data-model = { path = "../data-model" }
mas-email = { path = "../email" }
mas-i18n = { path = "../i18n" }
mas-matrix = { path = "../matrix" }
mas-storage = { path = "../storage" }
mas-storage-pg = { path = "../storage-pg" }
mas-templates = { path = "../templates" }
mas-tower = { path = "../tower" }

View File

@ -15,8 +15,10 @@
use anyhow::Context;
use apalis_core::{context::JobContext, executor::TokioExecutor, monitor::Monitor};
use chrono::Duration;
use mas_email::{Address, EmailVerificationContext, Mailbox};
use mas_email::{Address, Mailbox};
use mas_i18n::locale;
use mas_storage::job::{JobWithSpanContext, VerifyEmailJob};
use mas_templates::{EmailVerificationContext, TemplateContext};
use rand::{distributions::Uniform, Rng};
use tracing::info;
@ -38,6 +40,11 @@ async fn verify_email(
let mailer = state.mailer();
let clock = state.clock();
let language = job
.language()
.and_then(|l| l.parse().ok())
.unwrap_or(locale!("en").into());
// Lookup the user email
let user_email = repo
.user_email()
@ -68,7 +75,8 @@ async fn verify_email(
// And send the verification email
let mailbox = Mailbox::new(Some(user.username.clone()), address);
let context = EmailVerificationContext::new(user.clone(), verification.clone());
let context =
EmailVerificationContext::new(user.clone(), verification.clone()).with_language(language);
mailer.send_verification_email(mailbox, &context).await?;