@@ -413,19 +413,16 @@ impl Encryption {
413
413
414
414
/// Get the E2EE identity of a user.
415
415
///
416
- /// Returns an error if this user does not exist, if there is an error
417
- /// contacting the crypto store, or if our client is not logged in.
416
+ /// Returns Ok(None) if this user does not exist.
417
+ ///
418
+ /// Returns an error if there was a problem contacting the crypto store, or
419
+ /// if our client is not logged in.
418
420
pub async fn get_user_identity (
419
421
& self ,
420
422
user_id : String ,
421
- ) -> Result < Arc < UserIdentity > , ClientError > {
422
- Ok ( Arc :: new ( UserIdentity {
423
- inner : self
424
- . inner
425
- . get_user_identity ( user_id. as_str ( ) . try_into ( ) ?)
426
- . await ?
427
- . ok_or ( ClientError :: new ( "User not found" ) ) ?,
428
- } ) )
423
+ ) -> Result < Option < Arc < UserIdentity > > , ClientError > {
424
+ let identity = self . inner . get_user_identity ( user_id. as_str ( ) . try_into ( ) ?) . await ?;
425
+ Ok ( identity. map ( |i| Arc :: new ( UserIdentity { inner : i } ) ) )
429
426
}
430
427
}
431
428
@@ -454,6 +451,16 @@ impl UserIdentity {
454
451
pub ( crate ) async fn pin ( & self ) -> Result < ( ) , ClientError > {
455
452
Ok ( self . inner . pin ( ) . await ?)
456
453
}
454
+
455
+ /// Get the public part of the Master key of this user identity.
456
+ ///
457
+ /// The public part of the Master key is usually used to uniquely identify
458
+ /// the identity.
459
+ ///
460
+ /// Returns None if the master key does not actually contain any keys.
461
+ pub ( crate ) fn master_key ( & self ) -> Option < String > {
462
+ self . inner . master_key ( ) . get_first_key ( ) . map ( |k| k. to_base64 ( ) )
463
+ }
457
464
}
458
465
459
466
#[ derive( uniffi:: Object ) ]
0 commit comments