pub async fn receive_forwarded_room_key(
        &self,
        sender_key: &str,
        event: &mut ToDeviceEvent<ForwardedRoomKeyEventContent>,
    ) -> Result<Option<Raw<AnyToDeviceEvent>>, CryptoStoreError> {
        let key_info = self.get_key_info(&event.content).await?;

        if let Some(info) = key_info {
            let session = InboundGroupSession::from_forwarded_key(sender_key, &mut event.content)?;

            let old_session = self
                .store
                .get_inbound_group_session(
                    session.room_id(),
                    &session.sender_key,
                    session.session_id(),
                )
                .await?;

            // If we have a previous session, check if we have a better version
            // and store the new one if so.
            if let Some(old_session) = old_session {
                let first_old_index = old_session.first_known_index().await;
                let first_index = session.first_known_index().await;

                if first_old_index > first_index {
                    self.save_session(info, session).await?;
                }
            // If we didn't have a previous session, store it.
            } else {
                self.save_session(info, session).await?;
            }

            Ok(Some(Raw::from(AnyToDeviceEvent::ForwardedRoomKey(
                event.clone(),
            ))))
        } else {
            info!(
                "Received a forwarded room key from {}, but no key info was found.",
                event.sender,
            );
            Ok(None)
        }
    }
/// Receive a forwarded room key event.
Receive a forwarded room key event.
Receive a forwarded room key event .
pub async fn receive_forwarded_room_key(
        &self,
        sender_key: &str,
        event: &mut ToDeviceEvent<ForwardedRoomKeyEventContent>,
    ) -> Result<Option<Raw<AnyToDeviceEvent>>, CryptoStoreError> {
        let key_info = self.get_key_info(&event.content).await?;
        if let Some(info) = key_info {
            let session = InboundGroupSession::from_forwarded_key(sender_key, &mut event.content)?;
            let old_session = self
                .store
                .get_inbound_group_session(
                    session.room_id(),
                    &session.sender_key,
                    session.session_id(),
                )
                .await?;
            // If we have a previous session, check if we have a better version
            // and store the new one if so.
            if let Some(old_session) = old_session {
                let first_old_index = old_session.first_known_index().await;
                let first_index = session.first_known_index().await;
                if first_old_index > first_index {
                    self.save_session(info, session).await?;
                }
            // If we didn't have a previous session, store it.
            } else {
                self.save_session(info, session).await?;
            }
            Ok(Some(Raw::from(AnyToDeviceEvent::ForwardedRoomKey(
                event.clone(),
            ))))
        } else {
            info!(
                "Received a forwarded room key from {}, but no key info was found.",
                event.sender,
            );
            Ok(None)
        }
    }
pub async fn receive_forwarded_room_key ( & self , sender_key : & str , event : & mut ToDeviceEvent < ForwardedRoomKeyEventContent > , ) -> Result < Option < Raw < AnyToDeviceEvent > > , CryptoStoreError > { let key_info = self . get_key_info ( & event . content ) . await ? ; if let Some ( info ) = key_info { let session = InboundGroupSession :: from_forwarded_key ( sender_key , & mut event . content ) ? ; let old_session = self . store . get_inbound_group_session ( session . room_id ( ) , & session . sender_key , session . session_id ( ) , ) . await ? ; // If we have a previous session, check if we have a better version // and store the new one if so. if let Some ( old_session ) = old_session { let first_old_index = old_session . first_known_index ( ) . await ; let first_index = session . first_known_index ( ) . await ; if first_old_index > first_index { self . save_session ( info , session ) . await ? ; } // If we didn't have a previous session, store it. } else { self . save_session ( info , session ) . await ? ; } Ok ( Some ( Raw :: from ( AnyToDeviceEvent :: ForwardedRoomKey ( event . clone ( ) , ) ) ) ) } else { info ! ( " " event sender ) ; Ok ( None ) } }
Receive a forwarded room key event.
Receive a forwarded room key event .
&self
sender_key
&str
event
&mut ToDeviceEvent<ForwardedRoomKeyEventContent>
&self
sender_key
&str
event
&mut ToDeviceEvent<ForwardedRoomKeyEventContent>