Update Mutual Rooms (MSC2666) implementation (#1547)
This commit is contained in:
parent
dcbb5ec432
commit
01344edc8d
@ -17,7 +17,7 @@ pub mod unstable {
|
|||||||
rate_limited: true,
|
rate_limited: true,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
unstable => "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms/:user_id",
|
unstable => "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,8 +25,14 @@ pub mod unstable {
|
|||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The user to search mutual rooms for.
|
/// The user to search mutual rooms for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(query)]
|
||||||
pub user_id: OwnedUserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
|
/// The `next_batch_token` returned from a previous response, to get the next batch of
|
||||||
|
/// rooms.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
#[ruma_api(query)]
|
||||||
|
pub batch_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `mutual_rooms` endpoint.
|
/// Response type for the `mutual_rooms` endpoint.
|
||||||
@ -34,19 +40,33 @@ pub mod unstable {
|
|||||||
pub struct Response {
|
pub struct Response {
|
||||||
/// A list of rooms the user is in together with the authenticated user.
|
/// A list of rooms the user is in together with the authenticated user.
|
||||||
pub joined: Vec<OwnedRoomId>,
|
pub joined: Vec<OwnedRoomId>,
|
||||||
|
|
||||||
|
/// An opaque string, returned when the server paginates this response.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub next_batch_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user id.
|
/// Creates a new `Request` with the given user id.
|
||||||
pub fn new(user_id: OwnedUserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id, batch_token: None }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new `Request` with the given user id, together with a batch token.
|
||||||
|
pub fn with_token(user_id: OwnedUserId, token: String) -> Self {
|
||||||
|
Self { user_id, batch_token: Some(token) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a `Response` with the given room ids.
|
/// Creates a `Response` with the given room ids.
|
||||||
pub fn new(joined: Vec<OwnedRoomId>) -> Self {
|
pub fn new(joined: Vec<OwnedRoomId>) -> Self {
|
||||||
Self { joined }
|
Self { joined, next_batch_token: None }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a `Response` with the given room ids, together with a batch token.
|
||||||
|
pub fn with_token(joined: Vec<OwnedRoomId>, token: String) -> Self {
|
||||||
|
Self { joined, next_batch_token: Some(token) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user