fix(message): make markseen_msgs async compatible

Otherwise this method can not be called from an actually spawned async method, as `PreparedStatement` is `!Send`
This commit is contained in:
Friedel Ziegelmayer
2021-07-29 15:47:52 +02:00
committed by GitHub
parent 57870ec54a
commit e22a9999d7

View File

@@ -1417,6 +1417,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
} }
let conn = context.sql.get_conn().await?; let conn = context.sql.get_conn().await?;
let msgs = async_std::task::spawn_blocking(move || -> Result<_> {
let mut stmt = conn.prepare_cached(concat!( let mut stmt = conn.prepare_cached(concat!(
"SELECT", "SELECT",
" m.chat_id AS chat_id,", " m.chat_id AS chat_id,",
@@ -1444,6 +1445,9 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
} }
drop(stmt); drop(stmt);
drop(conn); drop(conn);
Ok(msgs)
})
.await?;
let mut updated_chat_ids = BTreeMap::new(); let mut updated_chat_ids = BTreeMap::new();