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)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
||||
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox};
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -24,7 +24,7 @@ ruma_api! {
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// A list of servers that are aware of this room ID.
|
||||
pub servers: Vec<String>,
|
||||
pub servers: Vec<ServerNameBox>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
@ -39,7 +39,7 @@ impl<'a> Request<'a> {
|
||||
|
||||
impl Response {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_common::directory::PublicRoomsChunk;
|
||||
use ruma_identifiers::ServerName;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -31,7 +32,7 @@ ruma_api! {
|
||||
/// `None` means the server this request is sent to.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub server: Option<&'a str>,
|
||||
pub server: Option<&'a ServerName>,
|
||||
}
|
||||
|
||||
response: {
|
||||
@ -79,10 +80,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn construct_request_from_refs() {
|
||||
let req: http::Request<Vec<u8>> =
|
||||
Request { limit: Some(uint!(10)), since: Some("hello"), server: Some("address") }
|
||||
.try_into_http_request("https://homeserver.tld", Some("auth_tok"))
|
||||
.unwrap();
|
||||
let req: http::Request<Vec<u8>> = Request {
|
||||
limit: Some(uint!(10)),
|
||||
since: Some("hello"),
|
||||
server: Some("address".try_into().unwrap()),
|
||||
}
|
||||
.try_into_http_request("https://homeserver.tld", Some("auth_tok"))
|
||||
.unwrap();
|
||||
|
||||
let uri = req.uri();
|
||||
let query = uri.query().unwrap();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::ServerName;
|
||||
use ruma_common::directory::{
|
||||
Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork,
|
||||
};
|
||||
@ -23,7 +24,7 @@ ruma_api! {
|
||||
/// `None` means the server this request is sent to.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub server: Option<&'a str>,
|
||||
pub server: Option<&'a ServerName>,
|
||||
|
||||
/// Limit for the number of results to return.
|
||||
#[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)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
||||
use ruma_identifiers::{RoomAliasId, RoomId, ServerNameBox};
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -24,7 +24,7 @@ ruma_api! {
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// 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 {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user