refactor(sql): add query_map_vec()

This also replaces some cases where flatten()
was used, effectively ignoring the errors.
This commit is contained in:
link2xt
2025-10-24 00:58:58 +00:00
committed by l
parent 45a1d81805
commit 5f3948b462
16 changed files with 83 additions and 203 deletions

View File

@@ -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,