commit - 91d924e2ff7408d4e6b66378d7af3bf48cef4a69
commit + 6f8eb2710134cde1501dfca708fda3d16d9ab578
blob - 27647b749a7d30aaed1c384cbb69766e882b6935
blob + 4edbfe45d73e6a659b7ef084fc113a6a6fbd6406
--- src/main.rs
+++ src/main.rs
config: &AppConfig,
mut conn: PoolConnection<Sqlite>,
mut rx: Receiver<Post>,
+ dry_run: bool,
) -> Result<(), Error> {
let mailer = get_mailer(
config.smtp_user.clone(),
&config.mail_from,
&config.mail_to,
post,
+ dry_run,
)
.await?;
}
}
let conn = pool.acquire().await.context(GeneralDatabaseSnafu)?;
join_set.spawn(async move { accumulator(conn, acc_rx, acc_tx).await });
- if !config.dry_run {
- let conn = pool.acquire().await.context(GeneralDatabaseSnafu)?;
- join_set.spawn(async move { sender(&config, conn, send_rx).await });
- }
+ let conn = pool.acquire().await.context(GeneralDatabaseSnafu)?;
+ join_set.spawn(async move { sender(&config, conn, send_rx, config.dry_run).await });
while let Some(task) = join_set.join_next().await {
if let Err(e) = task {
from: &'a str,
to: &'a str,
post: models::Post,
+ dry_run: bool,
) -> Result<(), Error> {
- log::debug!("Sending post with guid '{}'", post.guid);
- Mail::new(post.title, post.content, post.url)
- .send_email(from, to, &mailer)
- .await
- .context(MailSnafu)?;
+ if !dry_run {
+ log::debug!("Sending post with guid '{}'", post.guid);
+ Mail::new(post.title, post.content, post.url)
+ .send_email(from, to, &mailer)
+ .await
+ .context(MailSnafu)?;
+ }
set_sent(&post.guid, conn).await?;