Skip to content

Commit e6c8e45

Browse files
committed
fix: skip failed email
1 parent 60a4bd3 commit e6c8e45

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
@@ -47,11 +47,20 @@ fn check(emails: &Emails, conn: &mut PgConnection) -> anyhow::Result<()> {
4747
name: &user.gh_login,
4848
token_name: &token.name,
4949
};
50-
emails.send(&recipient, email)?;
51-
// Also update the token to prevent duplicate notifications.
52-
diesel::update(token)
53-
.set(crate::schema::api_tokens::expiry_notification_at.eq(now.nullable()))
54-
.execute(conn)?;
50+
match emails.send(&recipient, email) {
51+
Ok(_) => {
52+
// Update the token to prevent duplicate notifications.
53+
diesel::update(token)
54+
.set(
55+
crate::schema::api_tokens::expiry_notification_at
56+
.eq(now.nullable()),
57+
)
58+
.execute(conn)?;
59+
}
60+
Err(e) => {
61+
error!("Failed to send email: {:?} to {}", e, recipient);
62+
}
63+
}
5564
}
5665
Ok::<_, anyhow::Error>(())
5766
})?;

0 commit comments

Comments
 (0)