diff --git a/src/lib.rs b/src/lib.rs index 7e63f61f..c98becf0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,7 +37,7 @@ pub mod r0 { pub mod room; pub mod search; pub mod send; -// pub mod server; + pub mod server; pub mod session; pub mod sync; // pub mod tag; diff --git a/src/r0/server.rs b/src/r0/server.rs index 1e5a64ac..0bf2fd95 100644 --- a/src/r0/server.rs +++ b/src/r0/server.rs @@ -2,9 +2,34 @@ /// [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-admin-whois-userid) pub mod get_user_info { + use std::collections::HashMap; + + use ruma_api_macros::ruma_api; use ruma_identifiers::UserId; - use std::collections::HashMap; + ruma_api! { + metadata { + description: "Get information about a particular user.", + method: Method::Get, + name: "get_user_info", + path: "/_matrix/client/r0/admin/whois/:user_id", + rate_limited: false, + requires_authentication: true, + } + + request { + /// The user to look up. + #[ruma_api(path)] + pub user_id: UserId, + } + + response { + /// The Matrix user ID of the user. + pub user_id: UserId, + /// A map of the user's device identifiers to information about that device. + pub devices: HashMap, + } + } /// Information about a connection in a user session. #[derive(Clone, Debug, Deserialize, Serialize)] @@ -24,68 +49,10 @@ pub mod get_user_info { pub sessions: Vec, } - /// Details about this API endpoint. - #[derive(Clone, Copy, Debug)] - pub struct Endpoint; - - /// This API endpoint's path parameters. - #[derive(Clone, Debug)] - pub struct PathParams { - /// The user to look up. - pub user_id: UserId, - } - - /// This API endpoint's response. - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct Response { - /// The Matrix user ID of the user. - pub user_id: UserId, - /// A map of the user's device identifiers to information about that device. - pub devices: HashMap, - } - /// Information about a user session. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SessionInfo { /// A list of connections in this session. pub connections: Vec, } - - impl ::Endpoint for Endpoint { - type BodyParams = (); - type PathParams = PathParams; - type QueryParams = (); - type Response = Response; - - fn method() -> ::Method { - ::Method::Get - } - - fn request_path(params: Self::PathParams) -> String { - format!( - "/_matrix/client/r0/admin/whois/{}", - params.user_id - ) - } - - fn router_path() -> &'static str { - "/_matrix/client/r0/admin/whois/:user_id" - } - - fn name() -> &'static str { - "get_user_info" - } - - fn description() -> &'static str { - "Get information about a particular user." - } - - fn requires_authentication() -> bool { - true - } - - fn rate_limited() -> bool { - false - } - } }