Skip to content

Commit aec34dd

Browse files
committed
controllers/github: Reuse existing database connection in send_notification_email() call
1 parent 18382c1 commit aec34dd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/controllers/github/secret_scanning.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn alert_revoke_token(
188188
"Active API token received and revoked (true positive)",
189189
);
190190

191-
if let Err(error) = send_notification_email(&token, alert, state) {
191+
if let Err(error) = send_notification_email(&token, alert, state, &conn) {
192192
warn!(
193193
token_id = %token.id, user_id = %token.user_id, ?error,
194194
"Failed to send email notification",
@@ -202,11 +202,10 @@ fn send_notification_email(
202202
token: &ApiToken,
203203
alert: &GitHubSecretAlert,
204204
state: &AppState,
205+
conn: &PgConnection,
205206
) -> anyhow::Result<()> {
206-
let conn = state.db_read()?;
207-
208-
let user = User::find(&conn, token.user_id).context("Failed to find user")?;
209-
let Some(email) = user.email(&conn)? else {
207+
let user = User::find(conn, token.user_id).context("Failed to find user")?;
208+
let Some(email) = user.email(conn)? else {
210209
return Err(anyhow!("No address found"));
211210
};
212211

0 commit comments

Comments
 (0)