public Promise < PeerSession > pickSession ( final int uid , final int keyGroupId , final long ownKeyId , final long theirKeyId ) { return pickCachedSession ( uid , keyGroupId , ownKeyId , theirKeyId ) . fallback ( new Function < Exception , Promise < PeerSession > > ( ) { @ Override public Promise < PeerSession > apply ( Exception e ) { return Promises . tuple ( keyManager . getOwnIdentity ( ) , keyManager . getOwnPreKey ( ownKeyId ) , keyManager . getUserKeyGroups ( uid ) , keyManager . getUserPreKey ( uid , keyGroupId , theirKeyId ) ) . map ( new FunctionTupled4 < KeyManagerActor . OwnIdentity , PrivateKey , UserKeys , PublicKey , PeerSession > ( ) { @ Override public PeerSession apply ( KeyManagerActor . OwnIdentity ownIdentity , PrivateKey ownPreKey , UserKeys userKeys , PublicKey theirPreKey ) { UserKeysGroup keysGroup = ManagedList . of ( userKeys . getUserKeysGroups ( ) ) . filter ( UserKeysGroup . BY_KEY_GROUP ( keyGroupId ) ) . first ( ) ; return spawnSession ( uid , ownIdentity . getKeyGroup ( ) , keyGroupId , ownIdentity . getIdentityKey ( ) , keysGroup . getIdentityKey ( ) , ownPreKey , theirPreKey ) ; } } ) ; } } ) ; }
Pick session for specific keys