File tree 4 files changed +14
-11
lines changed
4 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -1867,6 +1867,7 @@ pub(crate) async fn mark_contact_id_as_verified(
1867
1867
contact_id : ContactId ,
1868
1868
verifier_id : ContactId ,
1869
1869
) -> Result < ( ) > {
1870
+ debug_assert_ne ! ( contact_id, verifier_id, "Contact cannot be verified by self" ) ;
1870
1871
context
1871
1872
. sql
1872
1873
. transaction ( |transaction| {
@@ -1878,13 +1879,15 @@ pub(crate) async fn mark_contact_id_as_verified(
1878
1879
if contact_fingerprint. is_empty ( ) {
1879
1880
bail ! ( "Non-PGP contact {contact_id} cannot be verified." ) ;
1880
1881
}
1881
- let verifier_fingerprint: String = transaction. query_row (
1882
- "SELECT fingerprint FROM contacts WHERE id=?" ,
1883
- ( verifier_id, ) ,
1884
- |row| row. get ( 0 ) ,
1885
- ) ?;
1886
- if verifier_fingerprint. is_empty ( ) {
1887
- bail ! ( "Contact {contact_id} cannot be verified by non-PGP contact {verifier_id}." ) ;
1882
+ if verifier_id != ContactId :: SELF {
1883
+ let verifier_fingerprint: String = transaction. query_row (
1884
+ "SELECT fingerprint FROM contacts WHERE id=?" ,
1885
+ ( verifier_id, ) ,
1886
+ |row| row. get ( 0 ) ,
1887
+ ) ?;
1888
+ if verifier_fingerprint. is_empty ( ) {
1889
+ bail ! ( "Contact {contact_id} cannot be verified by non-PGP contact {verifier_id}." ) ;
1890
+ }
1888
1891
}
1889
1892
transaction. execute (
1890
1893
"UPDATE contacts SET verifier=? WHERE id=?" ,
Original file line number Diff line number Diff line change @@ -1168,7 +1168,7 @@ impl Context {
1168
1168
. await ?
1169
1169
. first ( )
1170
1170
. context ( "Self reporting bot vCard does not contain a contact" ) ?;
1171
- mark_contact_id_as_verified ( self , contact_id, contact_id ) . await ?;
1171
+ mark_contact_id_as_verified ( self , contact_id, ContactId :: SELF ) . await ?;
1172
1172
1173
1173
let chat_id = ChatId :: create_for_contact ( self , contact_id) . await ?;
1174
1174
chat_id
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ async fn verify_sender_by_fingerprint(
208
208
let contact = Contact :: get_by_id ( context, contact_id) . await ?;
209
209
let is_verified = contact. fingerprint ( ) . is_some_and ( |fp| & fp == fingerprint) ;
210
210
if is_verified {
211
- mark_contact_id_as_verified ( context, contact_id, contact_id ) . await ?;
211
+ mark_contact_id_as_verified ( context, contact_id, ContactId :: SELF ) . await ?;
212
212
}
213
213
Ok ( is_verified)
214
214
}
@@ -537,7 +537,7 @@ pub(crate) async fn observe_securejoin_on_other_device(
537
537
return Ok ( HandshakeMessage :: Ignore ) ;
538
538
} ;
539
539
540
- mark_contact_id_as_verified ( context, contact_id, contact_id ) . await ?;
540
+ mark_contact_id_as_verified ( context, contact_id, ContactId :: SELF ) . await ?;
541
541
542
542
ChatId :: set_protection_for_contact ( context, contact_id, mime_message. timestamp_sent ) . await ?;
543
543
Original file line number Diff line number Diff line change @@ -1370,7 +1370,7 @@ fn print_logevent(logevent: &LogEvent) {
1370
1370
/// and peerstate as backwards verified.
1371
1371
pub ( crate ) async fn mark_as_verified ( this : & TestContext , other : & TestContext ) {
1372
1372
let contact_id = this. add_or_lookup_contact_id ( other) . await ;
1373
- mark_contact_id_as_verified ( this, contact_id, contact_id )
1373
+ mark_contact_id_as_verified ( this, contact_id, ContactId :: SELF )
1374
1374
. await
1375
1375
. unwrap ( ) ;
1376
1376
}
You can’t perform that action at this time.
0 commit comments