Unsubscribe link in emails sent
This commit is contained in:
@@ -63,8 +63,25 @@ pub struct NewPostEmailTemplate<'a> {
|
||||
pub post_excerpt: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> NewPostEmailTemplate<'a> {
|
||||
pub fn text_version(&self) -> String {
|
||||
#[derive(Template)]
|
||||
#[template(path = "../templates/email/standalone.html")]
|
||||
pub struct StandaloneEmailTemplate<'a> {
|
||||
pub base_url: &'a str,
|
||||
pub html_content: &'a str,
|
||||
pub text_content: &'a str,
|
||||
}
|
||||
|
||||
pub trait EmailTemplate: Sync {
|
||||
fn html(&self) -> String;
|
||||
fn text(&self) -> String;
|
||||
}
|
||||
|
||||
impl<'a> EmailTemplate for NewPostEmailTemplate<'a> {
|
||||
fn html(&self) -> String {
|
||||
self.render().unwrap()
|
||||
}
|
||||
|
||||
fn text(&self) -> String {
|
||||
format!(
|
||||
r#"New post available!
|
||||
|
||||
@@ -86,10 +103,31 @@ Alphonse
|
||||
|
||||
zero2prod - Building better backends with Rust
|
||||
Visit the blog: {}
|
||||
Unsubscribe: {}/unsubscribe
|
||||
Unsubscribe: {}/unsubscribe?token=UNSUBSCRIBE_TOKEN
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EmailTemplate for StandaloneEmailTemplate<'a> {
|
||||
fn html(&self) -> String {
|
||||
self.render().unwrap()
|
||||
}
|
||||
|
||||
fn text(&self) -> String {
|
||||
format!(
|
||||
r#"{}
|
||||
|
||||
---
|
||||
|
||||
zero2prod - Building better backends with Rust
|
||||
Visit the blog: {}
|
||||
Unsubscribe: {}/unsubscribe?token=UNSUBSCRIBE_TOKEN
|
||||
|
||||
You're receiving this because you subscribed to the zero2prod newsletter."#,
|
||||
self.text_content, self.base_url, self.base_url
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user