HTML and plain text for new post mail notifications
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use askama::Template;
|
||||
|
||||
use crate::domain::PostEntry;
|
||||
use askama::Template;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Template)]
|
||||
pub enum MessageTemplate {
|
||||
@@ -49,3 +49,43 @@ pub struct ConfirmTemplate;
|
||||
#[derive(Template)]
|
||||
#[template(path = "../templates/404.html")]
|
||||
pub struct NotFoundTemplate;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "../templates/email/new_post.html")]
|
||||
pub struct NewPostEmailTemplate<'a> {
|
||||
pub base_url: &'a str,
|
||||
pub post_title: &'a str,
|
||||
pub post_id: &'a Uuid,
|
||||
pub post_excerpt: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> NewPostEmailTemplate<'a> {
|
||||
pub fn text_version(&self) -> String {
|
||||
format!(
|
||||
r#"New post available!
|
||||
|
||||
Hello there!
|
||||
I just published a new post that I think you'll find interesting:
|
||||
|
||||
"{}"
|
||||
|
||||
Read the full post: {}/posts/{}
|
||||
|
||||
This post covers practical insights and real-world examples that I hope will be valuable for your backend development journey.
|
||||
|
||||
Thanks for being a subscriber!
|
||||
|
||||
Best regards,
|
||||
Alphonse
|
||||
|
||||
---
|
||||
|
||||
zero2prod - Building better backends with Rust
|
||||
Visit the blog: {}
|
||||
Unsubscribe: {}/unsubscribe
|
||||
|
||||
You're receiving this because you subscribed to the zero2prod newsletter."#,
|
||||
self.post_title, self.base_url, self.post_id, self.base_url, self.base_url,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user