Skip to content

Commit 09df08f

Browse files
0xPoeTurbo87
authored andcommitted
fix: skip failed email
1 parent 65cf2c2 commit 09df08f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/worker/jobs/expiry_notification.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,20 @@ fn check(emails: &Emails, conn: &mut PgConnection) -> anyhow::Result<()> {
5353
token_name: &token.name,
5454
expiry_date: token.expired_at.unwrap().and_utc(),
5555
};
56-
emails.send(&recipient, email)?;
57-
// Also update the token to prevent duplicate notifications.
58-
diesel::update(token)
59-
.set(crate::schema::api_tokens::expiry_notification_at.eq(now.nullable()))
60-
.execute(conn)?;
56+
match emails.send(&recipient, email) {
57+
Ok(_) => {
58+
// Update the token to prevent duplicate notifications.
59+
diesel::update(token)
60+
.set(
61+
crate::schema::api_tokens::expiry_notification_at
62+
.eq(now.nullable()),
63+
)
64+
.execute(conn)?;
65+
}
66+
Err(e) => {
67+
error!("Failed to send email: {:?} to {}", e, recipient);
68+
}
69+
}
6170
}
6271
Ok::<_, anyhow::Error>(())
6372
})?;

0 commit comments

Comments
 (0)