@@ -1952,7 +1952,9 @@ async fn add_parts(
19521952 None ,
19531953 added_removed_id,
19541954 )
1955- . await ?;
1955+ . await
1956+ . log_err ( context)
1957+ . ok ( ) ;
19561958 }
19571959
19581960 if let Some ( node_addr) = mime_parser. get_header ( HeaderDef :: IrohNodeAddr ) {
@@ -2156,13 +2158,19 @@ RETURNING id
21562158 if let Some ( topic) = mime_parser. get_header ( HeaderDef :: IrohGossipTopic ) {
21572159 // default encoding of topic ids is `hex`.
21582160 let mut topic_raw = [ 0u8 ; 32 ] ;
2159- BASE32_NOPAD
2161+ if BASE32_NOPAD
21602162 . decode_mut ( topic. to_ascii_uppercase ( ) . as_bytes ( ) , & mut topic_raw)
21612163 . map_err ( |e| e. error )
2162- . context ( "Wrong gossip topic header" ) ?;
2163-
2164- let topic = TopicId :: from_bytes ( topic_raw) ;
2165- insert_topic_stub ( context, * msg_id, topic) . await ?;
2164+ . context ( "Wrong gossip topic header" )
2165+ . log_err ( context)
2166+ . is_ok ( )
2167+ {
2168+ let topic = TopicId :: from_bytes ( topic_raw) ;
2169+ insert_topic_stub ( context, * msg_id, topic)
2170+ . await
2171+ . log_err ( context)
2172+ . ok ( ) ;
2173+ }
21662174 } else {
21672175 warn ! ( context, "webxdc doesn't have a gossip topic" )
21682176 }
@@ -2175,7 +2183,9 @@ RETURNING id
21752183 part. param . get ( Param :: Filename ) ,
21762184 * msg_id,
21772185 )
2178- . await ?;
2186+ . await
2187+ . log_err ( context)
2188+ . ok ( ) ;
21792189 }
21802190
21812191 if let Some ( replace_msg_id) = replace_msg_id {
@@ -3647,7 +3657,10 @@ async fn mark_recipients_as_verified(
36473657 }
36483658
36493659 mark_contact_id_as_verified ( context, to_id, from_id) . await ?;
3650- ChatId :: set_protection_for_contact ( context, to_id, mimeparser. timestamp_sent ) . await ?;
3660+ ChatId :: set_protection_for_contact ( context, to_id, mimeparser. timestamp_sent )
3661+ . await
3662+ . log_err ( context)
3663+ . ok ( ) ;
36513664 }
36523665
36533666 Ok ( ( ) )
@@ -3709,21 +3722,24 @@ async fn add_or_lookup_contacts_by_address_list(
37093722) -> Result < Vec < Option < ContactId > > > {
37103723 let mut contact_ids = Vec :: new ( ) ;
37113724 for info in address_list {
3725+ contact_ids. push ( None ) ;
37123726 let addr = & info. addr ;
37133727 if !may_be_valid_addr ( addr) {
3714- contact_ids. push ( None ) ;
37153728 continue ;
37163729 }
37173730 let display_name = info. display_name . as_deref ( ) ;
3718- if let Ok ( addr) = ContactAddress :: new ( addr) {
3719- let ( contact_id, _) =
3720- Contact :: add_or_lookup ( context, display_name. unwrap_or_default ( ) , & addr, origin)
3721- . await ?;
3722- contact_ids. push ( Some ( contact_id) ) ;
3723- } else {
3731+ let Ok ( addr) = ContactAddress :: new ( addr) else {
37243732 warn ! ( context, "Contact with address {:?} cannot exist." , addr) ;
3725- contact_ids. push ( None ) ;
3726- }
3733+ continue ;
3734+ } ;
3735+ let contact_id =
3736+ Contact :: add_or_lookup ( context, display_name. unwrap_or_default ( ) , & addr, origin)
3737+ . await
3738+ . log_err ( context)
3739+ . ok ( )
3740+ . map ( |( id, _) | id) ;
3741+ contact_ids. pop ( ) ;
3742+ contact_ids. push ( contact_id) ;
37273743 }
37283744
37293745 Ok ( contact_ids)
@@ -3740,9 +3756,9 @@ async fn add_or_lookup_key_contacts_by_address_list(
37403756 let mut contact_ids = Vec :: new ( ) ;
37413757 let mut fingerprint_iter = fingerprints. iter ( ) ;
37423758 for info in address_list {
3759+ contact_ids. push ( None ) ;
37433760 let addr = & info. addr ;
37443761 if !may_be_valid_addr ( addr) {
3745- contact_ids. push ( None ) ;
37463762 continue ;
37473763 }
37483764 let fingerprint: String = if let Some ( fp) = fingerprint_iter. next ( ) {
@@ -3751,24 +3767,26 @@ async fn add_or_lookup_key_contacts_by_address_list(
37513767 } else if let Some ( key) = gossiped_keys. get ( addr) {
37523768 key. dc_fingerprint ( ) . hex ( )
37533769 } else {
3754- contact_ids. push ( None ) ;
37553770 continue ;
37563771 } ;
37573772 let display_name = info. display_name . as_deref ( ) ;
3758- if let Ok ( addr) = ContactAddress :: new ( addr) {
3759- let ( contact_id, _) = Contact :: add_or_lookup_ex (
3760- context,
3761- display_name. unwrap_or_default ( ) ,
3762- & addr,
3763- & fingerprint,
3764- origin,
3765- )
3766- . await ?;
3767- contact_ids. push ( Some ( contact_id) ) ;
3768- } else {
3773+ let Ok ( addr) = ContactAddress :: new ( addr) else {
37693774 warn ! ( context, "Contact with address {:?} cannot exist." , addr) ;
3770- contact_ids. push ( None ) ;
3771- }
3775+ continue ;
3776+ } ;
3777+ let contact_id = Contact :: add_or_lookup_ex (
3778+ context,
3779+ display_name. unwrap_or_default ( ) ,
3780+ & addr,
3781+ & fingerprint,
3782+ origin,
3783+ )
3784+ . await
3785+ . log_err ( context)
3786+ . ok ( )
3787+ . map ( |( id, _) | id) ;
3788+ contact_ids. pop ( ) ;
3789+ contact_ids. push ( contact_id) ;
37723790 }
37733791
37743792 ensure_and_debug_assert_eq ! ( contact_ids. len( ) , address_list. len( ) , ) ;
@@ -3899,35 +3917,41 @@ async fn lookup_key_contacts_by_address_list(
38993917 let mut contact_ids = Vec :: new ( ) ;
39003918 let mut fingerprint_iter = fingerprints. iter ( ) ;
39013919 for info in address_list {
3920+ contact_ids. push ( None ) ;
39023921 let addr = & info. addr ;
39033922 if !may_be_valid_addr ( addr) {
3904- contact_ids. push ( None ) ;
39053923 continue ;
39063924 }
39073925
3908- if let Some ( fp) = fingerprint_iter. next ( ) {
3926+ let contact_id = if let Some ( fp) = fingerprint_iter. next ( ) {
39093927 // Iterator has not ran out of fingerprints yet.
39103928 let display_name = info. display_name . as_deref ( ) ;
39113929 let fingerprint: String = fp. hex ( ) ;
39123930
3913- if let Ok ( addr) = ContactAddress :: new ( addr) {
3914- let ( contact_id, _) = Contact :: add_or_lookup_ex (
3915- context,
3916- display_name. unwrap_or_default ( ) ,
3917- & addr,
3918- & fingerprint,
3919- Origin :: Hidden ,
3920- )
3921- . await ?;
3922- contact_ids. push ( Some ( contact_id) ) ;
3923- } else {
3931+ let Ok ( addr) = ContactAddress :: new ( addr) else {
39243932 warn ! ( context, "Contact with address {:?} cannot exist." , addr) ;
3925- contact_ids. push ( None ) ;
3926- }
3933+ continue ;
3934+ } ;
3935+ Contact :: add_or_lookup_ex (
3936+ context,
3937+ display_name. unwrap_or_default ( ) ,
3938+ & addr,
3939+ & fingerprint,
3940+ Origin :: Hidden ,
3941+ )
3942+ . await
3943+ . log_err ( context)
3944+ . ok ( )
3945+ . map ( |( id, _) | id)
39273946 } else {
3928- let contact_id = lookup_key_contact_by_address ( context, addr, chat_id) . await ?;
3929- contact_ids. push ( contact_id) ;
3930- }
3947+ lookup_key_contact_by_address ( context, addr, chat_id)
3948+ . await
3949+ . log_err ( context)
3950+ . ok ( )
3951+ . flatten ( )
3952+ } ;
3953+ contact_ids. pop ( ) ;
3954+ contact_ids. push ( contact_id) ;
39313955 }
39323956 ensure_and_debug_assert_eq ! ( address_list. len( ) , contact_ids. len( ) , ) ;
39333957 Ok ( contact_ids)
0 commit comments