mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
refactor(sql): add query_map_vec()
This also replaces some cases where flatten() was used, effectively ignoring the errors.
This commit is contained in:
26
src/smtp.rs
26
src/smtp.rs
@@ -503,19 +503,10 @@ pub(crate) async fn send_smtp_messages(context: &Context, connection: &mut Smtp)
|
||||
|
||||
let rowids = context
|
||||
.sql
|
||||
.query_map(
|
||||
"SELECT id FROM smtp ORDER BY id ASC",
|
||||
(),
|
||||
|row| {
|
||||
let rowid: i64 = row.get(0)?;
|
||||
Ok(rowid)
|
||||
},
|
||||
|rowids| {
|
||||
rowids
|
||||
.collect::<std::result::Result<Vec<_>, _>>()
|
||||
.map_err(Into::into)
|
||||
},
|
||||
)
|
||||
.query_map_vec("SELECT id FROM smtp ORDER BY id ASC", (), |row| {
|
||||
let rowid: i64 = row.get(0)?;
|
||||
Ok(rowid)
|
||||
})
|
||||
.await?;
|
||||
|
||||
info!(context, "Selected rows from SMTP queue: {rowids:?}.");
|
||||
@@ -557,9 +548,9 @@ async fn send_mdn_rfc724_mid(
|
||||
}
|
||||
|
||||
// Try to aggregate additional MDNs into this MDN.
|
||||
let additional_rfc724_mids: Vec<String> = context
|
||||
let additional_rfc724_mids = context
|
||||
.sql
|
||||
.query_map(
|
||||
.query_map_vec(
|
||||
"SELECT rfc724_mid
|
||||
FROM smtp_mdns
|
||||
WHERE from_id=? AND rfc724_mid!=?",
|
||||
@@ -568,11 +559,8 @@ async fn send_mdn_rfc724_mid(
|
||||
let rfc724_mid: String = row.get(0)?;
|
||||
Ok(rfc724_mid)
|
||||
},
|
||||
|rows| rows.collect::<Result<Vec<_>, _>>().map_err(Into::into),
|
||||
)
|
||||
.await?
|
||||
.into_iter()
|
||||
.collect();
|
||||
.await?;
|
||||
|
||||
let mimefactory = MimeFactory::from_mdn(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user