Askama message template
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::{
|
||||
authentication::{self, AuthenticatedUser, Credentials, validate_credentials},
|
||||
routes::AdminError,
|
||||
startup::AppState,
|
||||
templates::SuccessTemplate,
|
||||
templates::MessageTemplate,
|
||||
};
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
@@ -47,8 +47,8 @@ pub async fn change_password(
|
||||
authentication::change_password(user_id, form.new_password, &connection_pool)
|
||||
.await
|
||||
.map_err(|e| AdminError::ChangePassword(e.to_string()))?;
|
||||
let template = SuccessTemplate {
|
||||
success_message: "Your password has been changed.".to_string(),
|
||||
let template = MessageTemplate::Success {
|
||||
message: "Your password has been changed.".to_string(),
|
||||
};
|
||||
Ok(Html(template.render().unwrap()).into_response())
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{
|
||||
idempotency::{IdempotencyKey, save_response, try_processing},
|
||||
routes::AdminError,
|
||||
startup::AppState,
|
||||
templates::SuccessTemplate,
|
||||
templates::MessageTemplate,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use askama::Template;
|
||||
@@ -98,11 +98,11 @@ pub async fn publish_newsletter(
|
||||
.await
|
||||
.context("Failed to enqueue delivery tasks.")?;
|
||||
|
||||
let success_message = format!(
|
||||
let message = format!(
|
||||
r#"The newsletter issue "{}" has been published!"#,
|
||||
form.title
|
||||
);
|
||||
let template = SuccessTemplate { success_message };
|
||||
let template = MessageTemplate::Success { message };
|
||||
let response = Html(template.render().unwrap()).into_response();
|
||||
save_response(transaction, &idempotency_key, user_id, response)
|
||||
.await
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{
|
||||
idempotency::{IdempotencyKey, save_response, try_processing},
|
||||
routes::{AdminError, enqueue_delivery_tasks, insert_newsletter_issue},
|
||||
startup::AppState,
|
||||
templates::SuccessTemplate,
|
||||
templates::MessageTemplate,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use askama::Template;
|
||||
@@ -68,8 +68,8 @@ pub async fn create_post(
|
||||
// Send emails with unique identifiers that contains link to blog post with special param
|
||||
// Get handpoint that returns the post and mark the email as opened
|
||||
|
||||
let template = SuccessTemplate {
|
||||
success_message: "Your new post has been saved. Subscribers will be notified.".into(),
|
||||
let template = MessageTemplate::Success {
|
||||
message: "Your new post has been saved. Subscribers will be notified.".into(),
|
||||
};
|
||||
let response = Html(template.render().unwrap()).into_response();
|
||||
save_response(transaction, &idempotency_key, user_id, response)
|
||||
|
||||
Reference in New Issue
Block a user