@@ -925,9 +925,9 @@ impl ChatId {
925925 /// Chat is considered active if something was posted there within the last 42 days.
926926 pub async fn get_similar_chat_ids ( self , context : & Context ) -> Result < Vec < ( ChatId , f64 ) > > {
927927 // Count number of common members in this and other chats.
928- let intersection: Vec < ( ChatId , f64 ) > = context
928+ let intersection = context
929929 . sql
930- . query_map (
930+ . query_map_vec (
931931 "SELECT y.chat_id, SUM(x.contact_id = y.contact_id)
932932 FROM chats_contacts as x
933933 JOIN chats_contacts as y
@@ -945,10 +945,6 @@ impl ChatId {
945945 let intersection: f64 = row. get ( 1 ) ?;
946946 Ok ( ( chat_id, intersection) )
947947 } ,
948- |rows| {
949- rows. collect :: < std:: result:: Result < Vec < _ > , _ > > ( )
950- . map_err ( Into :: into)
951- } ,
952948 )
953949 . await
954950 . context ( "failed to calculate member set intersections" ) ?;
@@ -2010,7 +2006,7 @@ impl Chat {
20102006 let self_fp = self_fingerprint ( context) . await ?;
20112007 let fingerprint_addrs = context
20122008 . sql
2013- . query_map (
2009+ . query_map_vec (
20142010 "SELECT c.id, c.fingerprint, c.addr
20152011 FROM contacts c INNER JOIN chats_contacts cc
20162012 ON c.id=cc.contact_id
@@ -2024,22 +2020,20 @@ impl Chat {
20242020 let addr = row. get ( 2 ) ?;
20252021 Ok ( ( fingerprint, addr) )
20262022 } ,
2027- |addrs| addrs. collect :: < Result < Vec < _ > , _ > > ( ) . map_err ( Into :: into) ,
20282023 )
20292024 . await ?;
20302025 self . sync ( context, SyncAction :: SetPgpContacts ( fingerprint_addrs) )
20312026 . await ?;
20322027 } else {
20332028 let addrs = context
20342029 . sql
2035- . query_map (
2030+ . query_map_vec (
20362031 "SELECT c.addr \
20372032 FROM contacts c INNER JOIN chats_contacts cc \
20382033 ON c.id=cc.contact_id \
20392034 WHERE cc.chat_id=? AND cc.add_timestamp >= cc.remove_timestamp",
20402035 ( self . id , ) ,
20412036 |row| row. get :: < _ , String > ( 0 ) ,
2042- |addrs| addrs. collect :: < Result < Vec < _ > , _ > > ( ) . map_err ( Into :: into) ,
20432037 )
20442038 . await ?;
20452039 self . sync ( context, SyncAction :: SetContacts ( addrs) ) . await ?;
@@ -3125,13 +3119,12 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
31253119 if chat_id. is_archived_link ( ) {
31263120 let chat_ids_in_archive = context
31273121 . sql
3128- . query_map (
3122+ . query_map_vec (
31293123 "SELECT DISTINCT(m.chat_id) FROM msgs m
31303124 LEFT JOIN chats c ON m.chat_id=c.id
31313125 WHERE m.state=10 AND m.hidden=0 AND m.chat_id>9 AND c.archived=1" ,
31323126 ( ) ,
31333127 |row| row. get :: < _ , ChatId > ( 0 ) ,
3134- |ids| ids. collect :: < Result < Vec < _ > , _ > > ( ) . map_err ( Into :: into) ,
31353128 )
31363129 . await ?;
31373130 if chat_ids_in_archive. is_empty ( ) {
@@ -3175,7 +3168,7 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
31753168 // locally (i.e. when the chat was opened locally).
31763169 let hidden_messages = context
31773170 . sql
3178- . query_map (
3171+ . query_map_vec (
31793172 "SELECT id, rfc724_mid FROM msgs
31803173 WHERE state=?
31813174 AND hidden=1
@@ -3187,10 +3180,6 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
31873180 let rfc724_mid: String = row. get ( 1 ) ?;
31883181 Ok ( ( msg_id, rfc724_mid) )
31893182 } ,
3190- |rows| {
3191- rows. collect :: < std:: result:: Result < Vec < _ > , _ > > ( )
3192- . map_err ( Into :: into)
3193- } ,
31943183 )
31953184 . await ?;
31963185 for ( msg_id, rfc724_mid) in & hidden_messages {
@@ -3299,7 +3288,7 @@ pub async fn get_chat_media(
32993288 {
33003289 context
33013290 . sql
3302- . query_map (
3291+ . query_map_vec (
33033292 "SELECT id
33043293 FROM msgs
33053294 WHERE (1=? OR chat_id=?)
@@ -3314,13 +3303,12 @@ pub async fn get_chat_media(
33143303 Viewtype :: Webxdc ,
33153304 ) ,
33163305 |row| row. get :: < _ , MsgId > ( 0 ) ,
3317- |ids| Ok ( ids. flatten ( ) . collect ( ) ) ,
33183306 )
33193307 . await ?
33203308 } else {
33213309 context
33223310 . sql
3323- . query_map (
3311+ . query_map_vec (
33243312 "SELECT id
33253313 FROM msgs
33263314 WHERE (1=? OR chat_id=?)
@@ -3345,7 +3333,6 @@ pub async fn get_chat_media(
33453333 } ,
33463334 ) ,
33473335 |row| row. get :: < _ , MsgId > ( 0 ) ,
3348- |ids| Ok ( ids. flatten ( ) . collect ( ) ) ,
33493336 )
33503337 . await ?
33513338 } ;
@@ -3356,10 +3343,9 @@ pub async fn get_chat_media(
33563343pub async fn get_chat_contacts ( context : & Context , chat_id : ChatId ) -> Result < Vec < ContactId > > {
33573344 // Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a
33583345 // groupchat but the chats stays visible, moreover, this makes displaying lists easier)
3359-
3360- let list = context
3346+ context
33613347 . sql
3362- . query_map (
3348+ . query_map_vec (
33633349 "SELECT cc.contact_id
33643350 FROM chats_contacts cc
33653351 LEFT JOIN contacts c
@@ -3368,21 +3354,18 @@ pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result<Vec
33683354 ORDER BY c.id=1, c.last_seen DESC, c.id DESC;" ,
33693355 ( chat_id, ) ,
33703356 |row| row. get :: < _ , ContactId > ( 0 ) ,
3371- |ids| ids. collect :: < Result < Vec < _ > , _ > > ( ) . map_err ( Into :: into) ,
33723357 )
3373- . await ?;
3374-
3375- Ok ( list)
3358+ . await
33763359}
33773360
33783361/// Returns a vector of contact IDs for given chat ID that are no longer part of the group.
33793362///
33803363/// Members that have been removed recently are in the beginning of the list.
33813364pub async fn get_past_chat_contacts ( context : & Context , chat_id : ChatId ) -> Result < Vec < ContactId > > {
33823365 let now = time ( ) ;
3383- let list = context
3366+ context
33843367 . sql
3385- . query_map (
3368+ . query_map_vec (
33863369 "SELECT cc.contact_id
33873370 FROM chats_contacts cc
33883371 LEFT JOIN contacts c
@@ -3393,11 +3376,8 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
33933376 ORDER BY c.id=1, cc.remove_timestamp DESC, c.id DESC" ,
33943377 ( chat_id, now. saturating_sub ( 60 * 24 * 3600 ) ) ,
33953378 |row| row. get :: < _ , ContactId > ( 0 ) ,
3396- |ids| ids. collect :: < Result < Vec < _ > , _ > > ( ) . map_err ( Into :: into) ,
33973379 )
3398- . await ?;
3399-
3400- Ok ( list)
3380+ . await
34013381}
34023382
34033383/// Creates an encrypted group chat.
0 commit comments