Use ruma_identifiers::ServerName in more endpoints
Co-authored-by: Timo Kösters <timo@koesters.xyz>
This commit is contained in:
parent
2bd533c085
commit
e1bedc819c
@ -1,7 +1,7 @@
|
|||||||
//! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-directory-room-roomalias)
|
//! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-directory-room-roomalias)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -24,7 +24,7 @@ ruma_api! {
|
|||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
|
|
||||||
/// A list of servers that are aware of this room ID.
|
/// A list of servers that are aware of this room ID.
|
||||||
pub servers: Vec<String>,
|
pub servers: Vec<ServerNameBox>,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
@ -39,7 +39,7 @@ impl<'a> Request<'a> {
|
|||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given room id and servers
|
/// Creates a new `Response` with the given room id and servers
|
||||||
pub fn new(room_id: RoomId, servers: Vec<String>) -> Self {
|
pub fn new(room_id: RoomId, servers: Vec<ServerNameBox>) -> Self {
|
||||||
Self { room_id, servers }
|
Self { room_id, servers }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::directory::PublicRoomsChunk;
|
use ruma_common::directory::PublicRoomsChunk;
|
||||||
|
use ruma_identifiers::ServerName;
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -31,7 +32,7 @@ ruma_api! {
|
|||||||
/// `None` means the server this request is sent to.
|
/// `None` means the server this request is sent to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub server: Option<&'a str>,
|
pub server: Option<&'a ServerName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
response: {
|
response: {
|
||||||
@ -79,8 +80,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn construct_request_from_refs() {
|
fn construct_request_from_refs() {
|
||||||
let req: http::Request<Vec<u8>> =
|
let req: http::Request<Vec<u8>> = Request {
|
||||||
Request { limit: Some(uint!(10)), since: Some("hello"), server: Some("address") }
|
limit: Some(uint!(10)),
|
||||||
|
since: Some("hello"),
|
||||||
|
server: Some("address".try_into().unwrap()),
|
||||||
|
}
|
||||||
.try_into_http_request("https://homeserver.tld", Some("auth_tok"))
|
.try_into_http_request("https://homeserver.tld", Some("auth_tok"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
use ruma_identifiers::ServerName;
|
||||||
use ruma_common::directory::{
|
use ruma_common::directory::{
|
||||||
Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork,
|
Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork,
|
||||||
};
|
};
|
||||||
@ -23,7 +24,7 @@ ruma_api! {
|
|||||||
/// `None` means the server this request is sent to.
|
/// `None` means the server this request is sent to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub server: Option<&'a str>,
|
pub server: Option<&'a ServerName>,
|
||||||
|
|
||||||
/// Limit for the number of results to return.
|
/// Limit for the number of results to return.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! [GET /_matrix/federation/v1/query/directory](https://matrix.org/docs/spec/server_server/r0.1.3#get-matrix-federation-v1-query-directory)
|
//! [GET /_matrix/federation/v1/query/directory](https://matrix.org/docs/spec/server_server/r0.1.3#get-matrix-federation-v1-query-directory)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -24,7 +24,7 @@ ruma_api! {
|
|||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
|
|
||||||
/// An array of server names that are likely to hold the given room.
|
/// An array of server names that are likely to hold the given room.
|
||||||
pub servers: Vec<String>,
|
pub servers: Vec<ServerNameBox>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ impl<'a> Request<'a> {
|
|||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given room IDs and servers.
|
/// Creates a new `Response` with the given room IDs and servers.
|
||||||
pub fn new(room_id: RoomId, servers: Vec<String>) -> Self {
|
pub fn new(room_id: RoomId, servers: Vec<ServerNameBox>) -> Self {
|
||||||
Self { room_id, servers }
|
Self { room_id, servers }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user