mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 19:06:35 +03:00
refactor(sql): add query_map_collect()
This commit is contained in:
@@ -320,9 +320,9 @@ async fn get_self_reaction(context: &Context, msg_id: MsgId) -> Result<Reaction>
|
||||
|
||||
/// Returns a structure containing all reactions to the message.
|
||||
pub async fn get_msg_reactions(context: &Context, msg_id: MsgId) -> Result<Reactions> {
|
||||
let reactions = context
|
||||
let reactions: BTreeMap<ContactId, Reaction> = context
|
||||
.sql
|
||||
.query_map(
|
||||
.query_map_collect(
|
||||
"SELECT contact_id, reaction FROM reactions WHERE msg_id=?",
|
||||
(msg_id,),
|
||||
|row| {
|
||||
@@ -330,7 +330,6 @@ pub async fn get_msg_reactions(context: &Context, msg_id: MsgId) -> Result<React
|
||||
let reaction: String = row.get(1)?;
|
||||
Ok((contact_id, Reaction::from(reaction.as_str())))
|
||||
},
|
||||
|rows| Ok(rows.collect::<rusqlite::Result<BTreeMap<_, _>>>()?),
|
||||
)
|
||||
.await?;
|
||||
Ok(Reactions { reactions })
|
||||
|
||||
Reference in New Issue
Block a user