client-api: Update a few more endpoints to the new API standards
This commit is contained in:
parent
e2406cc8f0
commit
38913946eb
@ -16,10 +16,11 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The room in which to send the event.
|
/// The room in which to send the event.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// The type of receipt to send.
|
/// The type of receipt to send.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -27,16 +28,33 @@ ruma_api! {
|
|||||||
|
|
||||||
/// The event ID to acknowledge up to.
|
/// The event ID to acknowledge up to.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: EventId,
|
pub event_id: &'a EventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room ID, receipt type and event ID.
|
||||||
|
pub fn new(room_id: &'a RoomId, receipt_type: ReceiptType, event_id: &'a EventId) -> Self {
|
||||||
|
Self { room_id, receipt_type, event_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The type of receipt.
|
/// The type of receipt.
|
||||||
#[derive(Clone, Copy, Debug, Display, EnumString)]
|
#[derive(Clone, Copy, Debug, Display, EnumString)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum ReceiptType {
|
pub enum ReceiptType {
|
||||||
/// m.read
|
/// m.read
|
||||||
#[strum(serialize = "m.read")]
|
#[strum(serialize = "m.read")]
|
||||||
|
@ -13,27 +13,29 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The ID of the room of the event to redact.
|
/// The ID of the room of the event to redact.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// The ID of the event to redact.
|
/// The ID of the event to redact.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: EventId,
|
pub event_id: &'a EventId,
|
||||||
|
|
||||||
/// The transaction ID for this event.
|
/// The transaction ID for this event.
|
||||||
///
|
///
|
||||||
/// Clients should generate a unique ID; it will be used by the server to ensure idempotency
|
/// Clients should generate a unique ID; it will be used by the server to ensure idempotency
|
||||||
/// of requests.
|
/// of requests.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub txn_id: String,
|
pub txn_id: &'a str,
|
||||||
|
|
||||||
/// The reason for the redaction.
|
/// The reason for the redaction.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<String>,
|
pub reason: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The ID of the redacted event.
|
/// The ID of the redacted event.
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
@ -41,3 +43,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room ID, event ID and transation ID.
|
||||||
|
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, txn_id: &'a str) -> Self {
|
||||||
|
Self { room_id, event_id, txn_id, reason: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given event ID.
|
||||||
|
pub fn new(event_id: EventId) -> Self {
|
||||||
|
Self { event_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,25 +16,42 @@ ruma_api! {
|
|||||||
rate_limited: true,
|
rate_limited: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The user who has started to type.
|
/// The user who has started to type.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId,
|
pub user_id: &'a UserId,
|
||||||
|
|
||||||
/// The room in which the user is typing.
|
/// The room in which the user is typing.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// Whether the user is typing within a length of time or not.
|
/// Whether the user is typing within a length of time or not.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub state: Typing,
|
pub state: Typing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given user ID, room ID and typing state.
|
||||||
|
pub fn new(user_id: &'a UserId, room_id: &'a RoomId, state: Typing) -> Self {
|
||||||
|
Self { user_id, room_id, state }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A mark for whether the user is typing within a length of time or not.
|
/// A mark for whether the user is typing within a length of time or not.
|
||||||
#[derive(Clone, Copy, Debug, Serialize)]
|
#[derive(Clone, Copy, Debug, Serialize)]
|
||||||
#[serde(into = "TypingInner")]
|
#[serde(into = "TypingInner")]
|
||||||
|
@ -14,8 +14,11 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {}
|
request: {}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The username to use.
|
/// The username to use.
|
||||||
pub username: String,
|
pub username: String,
|
||||||
@ -33,3 +36,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given username, password, TURN URIs and time-to-live.
|
||||||
|
pub fn new(username: String, password: String, uris: Vec<String>, ttl: Duration) -> Self {
|
||||||
|
Self { username, password, uris, ttl }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user