mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-10 17:03:20 -04:00
fix: don't overwrite the parent session when creating a child Client
This commit is contained in:
@@ -80,6 +80,15 @@ impl AuthSession {
|
||||
}
|
||||
}
|
||||
|
||||
/// Take the matrix user information of this session.
|
||||
pub fn into_meta(self) -> SessionMeta {
|
||||
match self {
|
||||
AuthSession::Matrix(session) => session.meta,
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
AuthSession::Oidc(session) => session.user.meta,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the access token of this session.
|
||||
pub fn access_token(&self) -> &str {
|
||||
match self {
|
||||
|
||||
@@ -1905,9 +1905,15 @@ impl Client {
|
||||
)),
|
||||
};
|
||||
|
||||
// Copy the parent's session into the child.
|
||||
// Copy the parent's session meta into the child. This initializes the in-memory
|
||||
// state store of the child client with `SessionMeta`, and regenerates
|
||||
// the `OlmMachine` if needs be.
|
||||
//
|
||||
// Note: we don't need to do a full `restore_session`, because this would
|
||||
// overwrite the session information shared with the parent too, and it
|
||||
// must be initialized at most once.
|
||||
if let Some(session) = self.session() {
|
||||
client.restore_session(session).await?;
|
||||
client.base_client().set_session_meta(session.into_meta()).await?;
|
||||
}
|
||||
|
||||
Ok(client)
|
||||
|
||||
Reference in New Issue
Block a user