Skip to content

Commit 811cc48

Browse files
committed
refactor: better email template
Signed-off-by: hi-rustin <[email protected]>
1 parent 4787b5a commit 811cc48

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/worker/jobs/expiry_notification.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn check(emails: &Emails, conn: &mut PgConnection) -> anyhow::Result<()> {
4747
return Err(anyhow!("No address found"));
4848
};
4949
let email = ExpiryNotificationEmail {
50+
name: user.gh_login.clone(),
5051
token_name: token.name.clone(),
5152
expiry_date: token.expired_at.unwrap().date().to_string(),
5253
};
@@ -65,17 +66,26 @@ fn check(emails: &Emails, conn: &mut PgConnection) -> anyhow::Result<()> {
6566

6667
#[derive(Debug, Clone)]
6768
struct ExpiryNotificationEmail {
69+
name: String,
6870
token_name: String,
6971
expiry_date: String,
7072
}
7173

7274
impl Email for ExpiryNotificationEmail {
73-
const SUBJECT: &'static str = "Token Expiry Notification";
75+
const SUBJECT: &'static str = "Your token is about to expire";
7476

7577
fn body(&self) -> String {
7678
format!(
77-
"The token {} is about to expire on {}. Please take action.",
78-
self.token_name, self.expiry_date
79+
r#"Hi @{name},
80+
81+
We noticed your token "{token_name}" will expire in about {EXPIRY_THRESHOLD} days.
82+
83+
If this token is still needed, visit https://crates.io/settings/tokens/new to generate a new one.
84+
85+
Thanks,
86+
The crates.io team"#,
87+
name = self.name,
88+
token_name = self.token_name,
7989
)
8090
}
8191
}

0 commit comments

Comments
 (0)