Skip to content

Commit 410afc9

Browse files
committed
worker/jobs/sync_admins: Migrate to Emails::async_send()
1 parent 53afac9 commit 410afc9

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/worker/jobs/sync_admins.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::email::Email;
22
use crate::schema::{emails, users};
3-
use crate::tasks::spawn_blocking;
43
use crate::worker::Environment;
54
use crates_io_worker::BackgroundJob;
65
use diesel::prelude::*;
@@ -142,27 +141,22 @@ impl BackgroundJob for SyncAdmins {
142141

143142
let email = AdminAccountEmail::new(added_admins, removed_admins);
144143

145-
spawn_blocking(move || {
146-
for database_admin in &database_admins {
147-
let (_, _, email_address) = database_admin;
148-
if let Some(email_address) = email_address {
149-
if let Err(error) = ctx.emails.send(email_address, email.clone()) {
150-
warn!(
151-
"Failed to send email to admin {} ({}, github_id: {}): {}",
152-
database_admin.1, email_address, database_admin.0, error
153-
);
154-
}
155-
} else {
144+
for database_admin in &database_admins {
145+
let (_, _, email_address) = database_admin;
146+
if let Some(email_address) = email_address {
147+
if let Err(error) = ctx.emails.async_send(email_address, email.clone()).await {
156148
warn!(
157-
"No email address found for admin {} (github_id: {})",
158-
database_admin.1, database_admin.0
149+
"Failed to send email to admin {} ({}, github_id: {}): {}",
150+
database_admin.1, email_address, database_admin.0, error
159151
);
160152
}
153+
} else {
154+
warn!(
155+
"No email address found for admin {} (github_id: {})",
156+
database_admin.1, database_admin.0
157+
);
161158
}
162-
163-
Ok::<_, anyhow::Error>(())
164-
})
165-
.await?;
159+
}
166160

167161
Ok(())
168162
}

0 commit comments

Comments
 (0)