@@ -1952,7 +1952,9 @@ async fn add_parts(
1952
1952
None ,
1953
1953
added_removed_id,
1954
1954
)
1955
- . await ?;
1955
+ . await
1956
+ . log_err ( context)
1957
+ . ok ( ) ;
1956
1958
}
1957
1959
1958
1960
if let Some ( node_addr) = mime_parser. get_header ( HeaderDef :: IrohNodeAddr ) {
@@ -2156,13 +2158,19 @@ RETURNING id
2156
2158
if let Some ( topic) = mime_parser. get_header ( HeaderDef :: IrohGossipTopic ) {
2157
2159
// default encoding of topic ids is `hex`.
2158
2160
let mut topic_raw = [ 0u8 ; 32 ] ;
2159
- BASE32_NOPAD
2161
+ if BASE32_NOPAD
2160
2162
. decode_mut ( topic. to_ascii_uppercase ( ) . as_bytes ( ) , & mut topic_raw)
2161
2163
. 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
+ }
2166
2174
} else {
2167
2175
warn ! ( context, "webxdc doesn't have a gossip topic" )
2168
2176
}
@@ -2175,7 +2183,9 @@ RETURNING id
2175
2183
part. param . get ( Param :: Filename ) ,
2176
2184
* msg_id,
2177
2185
)
2178
- . await ?;
2186
+ . await
2187
+ . log_err ( context)
2188
+ . ok ( ) ;
2179
2189
}
2180
2190
2181
2191
if let Some ( replace_msg_id) = replace_msg_id {
@@ -3647,7 +3657,10 @@ async fn mark_recipients_as_verified(
3647
3657
}
3648
3658
3649
3659
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 ( ) ;
3651
3664
}
3652
3665
3653
3666
Ok ( ( ) )
@@ -3709,21 +3722,24 @@ async fn add_or_lookup_contacts_by_address_list(
3709
3722
) -> Result < Vec < Option < ContactId > > > {
3710
3723
let mut contact_ids = Vec :: new ( ) ;
3711
3724
for info in address_list {
3725
+ contact_ids. push ( None ) ;
3712
3726
let addr = & info. addr ;
3713
3727
if !may_be_valid_addr ( addr) {
3714
- contact_ids. push ( None ) ;
3715
3728
continue ;
3716
3729
}
3717
3730
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 {
3724
3732
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) ;
3727
3743
}
3728
3744
3729
3745
Ok ( contact_ids)
@@ -3740,9 +3756,9 @@ async fn add_or_lookup_key_contacts_by_address_list(
3740
3756
let mut contact_ids = Vec :: new ( ) ;
3741
3757
let mut fingerprint_iter = fingerprints. iter ( ) ;
3742
3758
for info in address_list {
3759
+ contact_ids. push ( None ) ;
3743
3760
let addr = & info. addr ;
3744
3761
if !may_be_valid_addr ( addr) {
3745
- contact_ids. push ( None ) ;
3746
3762
continue ;
3747
3763
}
3748
3764
let fingerprint: String = if let Some ( fp) = fingerprint_iter. next ( ) {
@@ -3751,24 +3767,26 @@ async fn add_or_lookup_key_contacts_by_address_list(
3751
3767
} else if let Some ( key) = gossiped_keys. get ( addr) {
3752
3768
key. dc_fingerprint ( ) . hex ( )
3753
3769
} else {
3754
- contact_ids. push ( None ) ;
3755
3770
continue ;
3756
3771
} ;
3757
3772
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 {
3769
3774
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) ;
3772
3790
}
3773
3791
3774
3792
ensure_and_debug_assert_eq ! ( contact_ids. len( ) , address_list. len( ) , ) ;
@@ -3899,35 +3917,41 @@ async fn lookup_key_contacts_by_address_list(
3899
3917
let mut contact_ids = Vec :: new ( ) ;
3900
3918
let mut fingerprint_iter = fingerprints. iter ( ) ;
3901
3919
for info in address_list {
3920
+ contact_ids. push ( None ) ;
3902
3921
let addr = & info. addr ;
3903
3922
if !may_be_valid_addr ( addr) {
3904
- contact_ids. push ( None ) ;
3905
3923
continue ;
3906
3924
}
3907
3925
3908
- if let Some ( fp) = fingerprint_iter. next ( ) {
3926
+ let contact_id = if let Some ( fp) = fingerprint_iter. next ( ) {
3909
3927
// Iterator has not ran out of fingerprints yet.
3910
3928
let display_name = info. display_name . as_deref ( ) ;
3911
3929
let fingerprint: String = fp. hex ( ) ;
3912
3930
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 {
3924
3932
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)
3927
3946
} 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) ;
3931
3955
}
3932
3956
ensure_and_debug_assert_eq ! ( address_list. len( ) , contact_ids. len( ) , ) ;
3933
3957
Ok ( contact_ids)
0 commit comments