client-api: Make id_server and id_access_token in ThirdpartyIdCredentials optional fields

This commit is contained in:
Mikoto 2024-06-18 21:19:22 +00:00 committed by GitHub
parent b8f0cb8fac
commit afb5ae0102
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 13 deletions

View File

@ -6,6 +6,7 @@ Breaking changes:
as before. as before.
- Change type of `client_secret` field in `ThirdpartyIdCredentials` - Change type of `client_secret` field in `ThirdpartyIdCredentials`
from `Box<ClientSecret>` to `OwnedClientSecret` from `Box<ClientSecret>` to `OwnedClientSecret`
- Make `id_server` and `id_access_token` in `ThirdpartyIdCredentials` optional
Improvements: Improvements:

View File

@ -542,29 +542,25 @@ pub struct IncomingCustomThirdPartyId {
#[derive(Clone, Deserialize, Serialize)] #[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ThirdpartyIdCredentials { pub struct ThirdpartyIdCredentials {
/// Identity server session ID. /// Identity server (or homeserver) session ID.
pub sid: OwnedSessionId, pub sid: OwnedSessionId,
/// Identity server client secret. /// Identity server (or homeserver) client secret.
pub client_secret: OwnedClientSecret, pub client_secret: OwnedClientSecret,
/// Identity server URL. /// Identity server URL.
pub id_server: String, #[serde(skip_serializing_if = "Option::is_none")]
pub id_server: Option<String>,
/// Identity server access token. /// Identity server access token.
pub id_access_token: String, #[serde(skip_serializing_if = "Option::is_none")]
pub id_access_token: Option<String>,
} }
impl ThirdpartyIdCredentials { impl ThirdpartyIdCredentials {
/// Creates a new `ThirdpartyIdCredentials` with the given session ID, client secret, identity /// Creates a new `ThirdpartyIdCredentials` with the given session ID and client secret.
/// server address and access token. pub fn new(sid: OwnedSessionId, client_secret: OwnedClientSecret) -> Self {
pub fn new( Self { sid, client_secret, id_server: None, id_access_token: None }
sid: OwnedSessionId,
client_secret: OwnedClientSecret,
id_server: String,
id_access_token: String,
) -> Self {
Self { sid, client_secret, id_server, id_access_token }
} }
} }