diff --git a/crates/ruma-identity-service-api/src/association.rs b/crates/ruma-identity-service-api/src/association.rs index 69121888..13fd38b2 100644 --- a/crates/ruma-identity-service-api/src/association.rs +++ b/crates/ruma-identity-service-api/src/association.rs @@ -1,4 +1,5 @@ //! Endpoints to create associations with a Matrix ID on the identity server. +pub mod check_3pid_validity; pub mod email; pub mod msisdn; diff --git a/crates/ruma-identity-service-api/src/association/check_3pid_validity.rs b/crates/ruma-identity-service-api/src/association/check_3pid_validity.rs new file mode 100644 index 00000000..b87c57a5 --- /dev/null +++ b/crates/ruma-identity-service-api/src/association/check_3pid_validity.rs @@ -0,0 +1,3 @@ +//! Endpoint to determine the validity of a 3PID. + +pub mod v2; diff --git a/crates/ruma-identity-service-api/src/association/check_3pid_validity/v2.rs b/crates/ruma-identity-service-api/src/association/check_3pid_validity/v2.rs new file mode 100644 index 00000000..b682eed0 --- /dev/null +++ b/crates/ruma-identity-service-api/src/association/check_3pid_validity/v2.rs @@ -0,0 +1,53 @@ +//! [GET /_matrix/identity/v2/3pid/getValidated3pid](https://matrix.org/docs/spec/identity_service/r0.3.0#get-matrix-identity-v2-3pid-getvalidated3pid) + +use js_int::UInt; +use ruma_api::ruma_api; +use ruma_common::thirdparty::Medium; + +ruma_api! { + metadata: { + description: "Determines if a given 3PID has been validated by a user.", + method: GET, + name: "check_3pid_validity", + path: "/_matrix/identity/v2/3pid/getValidated3pid/", + rate_limited: false, + authentication: AccessToken, + } + + request: { + /// The Session ID generated by the `requestToken` call. + #[ruma_api(query)] + pub sid: &'a str, + + /// The client secret passed to the `requestToken` call. + #[ruma_api(query)] + pub client_secret: &'a str, + + } + + response: { + /// The medium type of the 3PID. + pub medium: Medium, + + /// The address of the 3PID being looked up. + pub address: String, + + /// Timestamp, in milliseconds, indicating the time that the 3PID was validated. + pub validated_at: UInt, + } + +} + +impl<'a> Request<'a> { + /// Creates a `Request` with the given Session ID and client secret. + pub fn new(sid: &'a str, client_secret: &'a str) -> Self { + Self { sid, client_secret } + } +} + +impl Response { + /// Creates a `Response` with the given medium, address and validation timestamp. + pub fn new(medium: Medium, address: String, validated_at: UInt) -> Self { + Self { medium, address, validated_at } + } +}