client-api: Update room endpoints to the new API standards
This commit is contained in:
parent
a012ad3532
commit
9f814a2415
@ -13,15 +13,32 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
request: {
|
request: {
|
||||||
/// The room ID to get aliases of.
|
/// The room ID to get aliases of.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: &'a RoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
response: {
|
response: {
|
||||||
aliases: Vec<RoomAliasId>,
|
/// The server's local aliases on the room.
|
||||||
|
pub aliases: Vec<RoomAliasId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room ID.
|
||||||
|
pub fn new(room_id: &'a RoomId) -> Self {
|
||||||
|
Self { room_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given aliases.
|
||||||
|
pub fn new(aliases: Vec<RoomAliasId>) -> Self {
|
||||||
|
Self { aliases }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,21 +15,37 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
request: {
|
request: {
|
||||||
/// The ID of the room the event is in.
|
/// The ID of the room the event is in.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// The ID of the event.
|
/// The ID of the event.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: EventId,
|
pub event_id: &'a EventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
response: {
|
response: {
|
||||||
/// Arbitrary JSON of the event body. Returns both room and state events.
|
/// Arbitrary JSON of the event body.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub event: Raw<AnyRoomEvent>,
|
pub event: Raw<AnyRoomEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room ID and event ID.
|
||||||
|
pub fn new(room_id: &'a RoomId, event_id: &'a EventId) -> Self {
|
||||||
|
Self { room_id, event_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given event.
|
||||||
|
pub fn new(event: Raw<AnyRoomEvent>) -> Self {
|
||||||
|
Self { event }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,23 +14,40 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
request: {
|
request: {
|
||||||
/// Room in which the event to be reported is located.
|
/// Room in which the event to be reported is located.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// Event to report.
|
/// Event to report.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: EventId,
|
pub event_id: &'a EventId,
|
||||||
|
|
||||||
/// Integer between -100 and 0 rating offensivness.
|
/// Integer between -100 and 0 rating offensivness.
|
||||||
pub score: Int,
|
pub score: Int,
|
||||||
|
|
||||||
/// Reason to report content. May be blank.
|
/// Reason to report content. May be blank.
|
||||||
pub reason: String,
|
pub reason: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room ID, event ID, score and reason.
|
||||||
|
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, score: Int, reason: &'a str) -> Self {
|
||||||
|
Self { room_id, event_id, score, reason }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! [POST /_matrix/client/r0/rooms/{roomId}/upgrade](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-upgrade)
|
//! [POST /_matrix/client/r0/rooms/{roomId}/upgrade](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-upgrade)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::{RoomId, RoomVersionId};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -13,15 +13,17 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
request: {
|
request: {
|
||||||
/// ID of the room to be upgraded.
|
/// ID of the room to be upgraded.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// New version for the room.
|
/// New version for the room.
|
||||||
pub new_version: String,
|
pub new_version: &'a RoomVersionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
response: {
|
response: {
|
||||||
/// ID of the new room.
|
/// ID of the new room.
|
||||||
pub replacement_room: RoomId,
|
pub replacement_room: RoomId,
|
||||||
@ -29,3 +31,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room ID and new room version.
|
||||||
|
pub fn new(room_id: &'a RoomId, new_version: &'a RoomVersionId) -> Self {
|
||||||
|
Self { room_id, new_version }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given room ID.
|
||||||
|
pub fn new(replacement_room: RoomId) -> Self {
|
||||||
|
Self { replacement_room }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user