/// Create a new session with another account given a pre-key Olm message.
///
/// Returns the newly created session or a `OlmSessionError` if creating a
/// session failed.
///
/// # Arguments
/// * `their_identity_key` - The other account's identitiy/curve25519 key.
///
/// * `message` - A pre-key Olm message that was sent to us by the other
/// account.
Create a new session with another account given a pre-key Olm message.
Returns the newly created session or a `OlmSessionError` if creating a
session failed.
Create a new session with another account given a pre - key Olm message . Returns the newly created session or a ` OlmSessionError ` if creating a session failed .
pub(crate) async fn create_inbound_session(
        &self,
        their_identity_key: &str,
        message: PreKeyMessage,
    ) -> Result<Session, OlmSessionError> {
        let session =
            self.inner.lock().await.create_inbound_session_from(their_identity_key, message)?;
        self.inner.lock().await.remove_one_time_keys(&session).expect(
            "Session was successfully created but the account doesn't hold a matching one-time key",
        );
        let now = Instant::now();
        let session_id = session.session_id();
        Ok(Session {
            user_id: self.user_id.clone(),
            device_id: self.device_id.clone(),
            our_identity_keys: self.identity_keys.clone(),
            inner: Arc::new(Mutex::new(session)),
            session_id: session_id.into(),
            sender_key: their_identity_key.into(),
            created_using_fallback_key: false,
            creation_time: Arc::new(now),
            last_use_time: Arc::new(now),
        })
    }
pub ( crate ) async fn create_inbound_session ( & self , their_identity_key : & str , message : PreKeyMessage , ) -> Result < Session , OlmSessionError > { let session = self . inner . lock ( ) . await . create_inbound_session_from ( their_identity_key , message ) ? ; self . inner . lock ( ) . await . remove_one_time_keys ( & session ) . expect ( " " , ) ; let now = Instant :: now ( ) ; let session_id = session . session_id ( ) ; Ok ( Session { user_id : self . user_id . clone ( ) , device_id : self . device_id . clone ( ) , our_identity_keys : self . identity_keys . clone ( ) , inner : Arc :: new ( Mutex :: new ( session ) ) , session_id : session_id . into ( ) , sender_key : their_identity_key . into ( ) , created_using_fallback_key : false , creation_time : Arc :: new ( now ) , last_use_time : Arc :: new ( now ) , } ) }
Create a new session with another account given a pre-key Olm message.
Create a new session with another account given a pre - key Olm message .
&self
their_identity_key
&str
message
PreKeyMessage