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

@@ -170,7 +170,7 @@ impl MsgId {
) -> Result<Vec<String>> {
context
.sql
.query_map(
.query_map_vec(
"SELECT folder, uid FROM imap WHERE rfc724_mid=?",
(rfc724_mid,),
|row| {
@@ -178,10 +178,6 @@ impl MsgId {
let uid: u32 = row.get("uid")?;
Ok(format!("</{folder}/;UID={uid}>"))
},
|rows| {
rows.collect::<std::result::Result<Vec<_>, _>>()
.map_err(Into::into)
},
)
.await
}
@@ -240,7 +236,7 @@ impl MsgId {
if let Ok(rows) = context
.sql
.query_map(
.query_map_vec(
"SELECT contact_id, timestamp_sent FROM msgs_mdns WHERE msg_id=?",
(self,),
|row| {
@@ -248,7 +244,6 @@ impl MsgId {
let ts: i64 = row.get(1)?;
Ok((contact_id, ts))
},
|rows| rows.collect::<Result<Vec<_>, _>>().map_err(Into::into),
)
.await
{
@@ -1426,7 +1421,7 @@ pub async fn get_msg_read_receipts(
) -> Result<Vec<(ContactId, i64)>> {
context
.sql
.query_map(
.query_map_vec(
"SELECT contact_id, timestamp_sent FROM msgs_mdns WHERE msg_id=?",
(msg_id,),
|row| {
@@ -1434,7 +1429,6 @@ pub async fn get_msg_read_receipts(
let ts: i64 = row.get(1)?;
Ok((contact_id, ts))
},
|rows| rows.collect::<Result<Vec<_>, _>>().map_err(Into::into),
)
.await
}