Update remaining r0.4.0 modules to r0.6.0

This commit is contained in:
Jonas Platte 2020-05-05 00:11:04 +02:00
parent e759c3821e
commit 1ca24515ad
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
40 changed files with 314 additions and 188 deletions

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/account/whoami](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-account-whoami)
//! [GET /_matrix/client/r0/account/whoami](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-account-whoami)
use ruma_api::ruma_api;

View File

@ -1,4 +1,4 @@
//! [DELETE /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.4.0.html#delete-matrix-client-r0-directory-room-roomalias)
//! [DELETE /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.0#delete-matrix-client-r0-directory-room-roomalias)
use ruma_api::ruma_api;
use ruma_identifiers::RoomAliasId;

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.4.0.html#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_identifiers::{RoomAliasId, RoomId};

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-user-userid-account-data-type)
//! [PUT /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-account-data-type)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
@ -18,11 +18,13 @@ ruma_api! {
/// Arbitrary JSON to store as config data.
#[ruma_api(body)]
pub data: JsonValue,
/// The event type of the account_data to set.
///
/// Custom types should be namespaced to avoid clashes.
#[ruma_api(path)]
pub event_type: String,
/// The ID of the user to set account_data for.
///
/// The access token must be authorized to make requests for this user ID.

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type)
//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, UserId};
@ -18,14 +18,17 @@ ruma_api! {
/// Arbitrary JSON to store as config data.
#[ruma_api(body)]
pub data: JsonValue,
/// The event type of the account_data to set.
///
/// Custom types should be namespaced to avoid clashes.
#[ruma_api(path)]
pub event_type: String,
/// The ID of the room to set account_data on.
#[ruma_api(path)]
pub room_id: RoomId,
/// The ID of the user to set account_data for.
///
/// The access token must be authorized to make requests for this user ID.

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-account-3pid-email-requesttoken)
//! [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-email-requesttoken)
use js_int::UInt;
use ruma_api::ruma_api;
@ -16,13 +16,29 @@ ruma_api! {
request {
/// Client-generated secret string used to protect this session.
pub client_secret: String,
/// The email address.
pub email: String,
/// The ID server to send the onward request to as a hostname with an appended colon and port number if the port is not the default.
/// A URL for the identity server to redirect the user to after
/// validation is completed.
#[serde(skip_serializing_if = "Option::is_none")]
pub next_link: Option<String>,
/// Used to distinguish protocol level retries from requests to re-send
/// the email.
pub send_attempt: UInt,
/// The identity server to send the onward request to as a hostname with
/// an appended colon and port number if the port is not the default.
#[serde(skip_serializing_if = "Option::is_none")]
pub id_server: Option<String>,
/// Used to distinguish protocol level retries from requests to re-send the email.
pub send_attempt: UInt,
/// An access token previously registered with the identity server.
///
/// Required if an `id_server` is supplied.
#[serde(skip_serializing_if = "Option::is_none")]
pub id_access_token: Option<String>,
}
response {}

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-context-eventid)
//! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-context-eventid)
use js_int::UInt;
use ruma_api::ruma_api;
@ -18,43 +18,63 @@ ruma_api! {
}
request {
/// The event to get context around.
#[ruma_api(path)]
pub event_id: EventId,
/// The maximum number of events to return.
///
/// Defaults to 10 if not supplied.
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<UInt>,
/// The room to get events from.
#[ruma_api(path)]
pub room_id: RoomId,
/// A RoomEventFilter to filter returned events with.
#[serde(skip_serializing_if = "Option::is_none")]
/// The event to get context around.
#[ruma_api(path)]
pub event_id: EventId,
/// The maximum number of events to return.
///
/// Defaults to 10.
#[ruma_api(query)]
#[serde(default = "default_limit", skip_serializing_if = "is_default_limit")]
pub limit: UInt,
/// A RoomEventFilter to filter returned events with.
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<RoomEventFilter>,
}
response {
/// A token that can be used to paginate forwards with.
pub end: String,
/// Details of the requested event.
pub event: EventJson<only::RoomEvent>,
/// A list of room events that happened just after the requested event, in chronological
/// order.
pub events_after: Vec<EventJson<only::RoomEvent>>,
/// A list of room events that happened just before the requested event, in
/// reverse-chronological order.
pub events_before: Vec<EventJson<only::RoomEvent>>,
/// A token that can be used to paginate backwards with.
pub start: String,
/// The state of the room at the last event returned.
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<String>,
/// A token that can be used to paginate forwards with.
#[serde(skip_serializing_if = "Option::is_none")]
pub end: Option<String>,
/// A list of room events that happened just before the requested event,
/// in reverse-chronological order.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub events_before: Vec<EventJson<only::RoomEvent>>,
/// Details of the requested event.
#[serde(skip_serializing_if = "Option::is_none")]
pub event: Option<EventJson<only::RoomEvent>>,
/// A list of room events that happened just after the requested event,
/// in chronological order.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub events_after: Vec<EventJson<only::RoomEvent>>,
/// The state of the room at the last event returned.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub state: Vec<EventJson<only::StateEvent>>,
}
error: crate::Error
}
fn default_limit() -> UInt {
UInt::from(10u32)
}
#[allow(clippy::trivially_copy_pass_by_ref)]
fn is_default_limit(val: &UInt) -> bool {
*val == default_limit()
}

View File

@ -184,21 +184,25 @@ pub struct FilterDefinition {
/// include more fields than were requested.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub event_fields: Option<Vec<String>>,
/// The format to use for events.
///
/// 'client' will return the events in a format suitable for clients. 'federation' will return
/// the raw event as received over federation. The default is 'client'.
#[serde(skip_serializing_if = "Option::is_none")]
pub event_format: Option<EventFormat>,
/// The user account data that isn't associated with rooms to include.
#[serde(skip_serializing_if = "Option::is_none")]
pub account_data: Option<Filter>,
/// Filters to be applied to room data.
#[serde(skip_serializing_if = "Option::is_none")]
pub room: Option<RoomFilter>,
/// The presence updates to include.
#[serde(skip_serializing_if = "Option::is_none")]
pub presence: Option<Filter>,
/// The user account data that isn't associated with rooms to include.
#[serde(skip_serializing_if = "Option::is_none")]
pub account_data: Option<Filter>,
/// Filters to be applied to room data.
#[serde(skip_serializing_if = "Option::is_none")]
pub room: Option<RoomFilter>,
}
impl FilterDefinition {

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/user/{userId}/filter](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-user-userid-filter)
//! [POST /_matrix/client/r0/user/{userId}/filter](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-filter)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
@ -16,14 +16,15 @@ ruma_api! {
}
request {
/// The filter definition.
#[ruma_api(body)]
pub filter: FilterDefinition,
/// The ID of the user uploading the filter.
///
/// The access token must be authorized to make requests for this user ID.
#[ruma_api(path)]
pub user_id: UserId,
/// The filter definition.
#[ruma_api(body)]
pub filter: FilterDefinition,
}
response {

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/user/{userId}/filter/{filterId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-user-userid-filter-filterid)
//! [GET /_matrix/client/r0/user/{userId}/filter/{filterId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-filter-filterid)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
@ -16,12 +16,13 @@ ruma_api! {
}
request {
/// The ID of the filter to download.
#[ruma_api(path)]
pub filter_id: String,
/// The user ID to download a filter for.
#[ruma_api(path)]
pub user_id: UserId,
/// The ID of the filter to download.
#[ruma_api(path)]
pub filter_id: String,
}
response {

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-media-r0-upload)
//! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-media-r0-upload)
use ruma_api::ruma_api;
@ -14,12 +14,15 @@ ruma_api! {
request {
/// The name of the file being uploaded.
#[serde(skip_serializing_if = "Option::is_none")]
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
/// The content type of the file being uploaded.
// TODO: This should be optional.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
/// The file contents to upload.
#[ruma_api(raw_body)]
pub file: Vec<u8>,

View File

@ -22,14 +22,17 @@ use crate::r0::thirdparty::Medium;
/// identity which has been invited to the room.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThirdPartySigned {
/// The Matrix ID of the invitee.
pub mxid: String,
/// The Matrix ID of the user who issued the invite.
pub sender: String,
/// A signatures object containing a signature of the entire signed object.
pub signatures: BTreeMap<String, BTreeMap<String, String>>,
/// The Matrix ID of the invitee.
pub mxid: String,
/// The state key of the m.third_party_invite event.
pub token: String,
/// A signatures object containing a signature of the entire signed object.
pub signatures: BTreeMap<String, BTreeMap<String, String>>,
}
/// Represents third party IDs to invite to the room.

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-ban)
//! [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-ban)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, UserId};
@ -14,14 +14,16 @@ ruma_api! {
}
request {
/// The reason for banning the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
/// The room to kick the user from.
#[ruma_api(path)]
pub room_id: RoomId,
/// The user to ban.
pub user_id: UserId,
/// The reason for banning the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
response {}

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-forget)
//! [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-forget)
use ruma_api::ruma_api;
use ruma_identifiers::RoomId;

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-join)
//! [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-join)
use ruma_api::ruma_api;
use ruma_identifiers::RoomId;
@ -19,6 +19,7 @@ ruma_api! {
/// The room where the user should be invited.
#[ruma_api(path)]
pub room_id: RoomId,
/// The signature of a `m.third_party_invite` token to prove that this user owns a third
/// party identity which has been invited to the room.
#[serde(skip_serializing_if = "Option::is_none")]

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/joined_rooms](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms)
//! [GET /_matrix/client/r0/joined_rooms](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-joined-rooms)
use ruma_api::ruma_api;
use ruma_identifiers::RoomId;
@ -16,8 +16,8 @@ ruma_api! {
request {}
response {
/// A list of the rooms the user is in, i.e.
/// the ID of each room in which the user has joined membership.
/// A list of the rooms the user is in, i.e. the ID of each room in
/// which the user has joined membership.
pub joined_rooms: Vec<RoomId>,
}

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-kick)
//! [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-kick)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, UserId};
@ -14,14 +14,16 @@ ruma_api! {
}
request {
/// The reason for kicking the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
/// The room to kick the user from.
#[ruma_api(path)]
pub room_id: RoomId,
/// The user to kick.
pub user_id: UserId,
/// The reason for kicking the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
response {}

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-leave)
//! [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-leave)
use ruma_api::ruma_api;
use ruma_identifiers::RoomId;

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-unban)
//! [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-unban)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, UserId};
@ -17,6 +17,7 @@ ruma_api! {
/// The room to unban the user from.
#[ruma_api(path)]
pub room_id: RoomId,
/// The user to unban.
pub user_id: UserId,
}

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-presence-userid-status)
//! [PUT /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-presence-userid-status)
use ruma_api::ruma_api;
use ruma_events::presence::PresenceState;
@ -15,14 +15,16 @@ ruma_api! {
}
request {
/// The new presence state.
pub presence: PresenceState,
/// The status message to attach to this state.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_msg: Option<String>,
/// The user whose presence state will be updated.
#[ruma_api(path)]
pub user_id: UserId,
/// The new presence state.
pub presence: PresenceState,
/// The status message to attach to this state.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_msg: Option<String>,
}
response {}

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid-avatar-url)
//! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid-avatar-url)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid-displayname)
//! [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid-displayname)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid)
//! [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
@ -23,6 +23,7 @@ ruma_api! {
/// The user's avatar URL, if set.
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
/// The user's display name, if set.
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>,

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-profile-userid-avatar-url)
//! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-profile-userid-avatar-url)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
@ -14,11 +14,12 @@ ruma_api! {
}
request {
/// The new avatar URL for the user.
pub avatar_url: String,
/// The user whose avatar URL will be set.
#[ruma_api(path)]
pub user_id: UserId
pub user_id: UserId,
/// The new avatar URL for the user.
pub avatar_url: String,
}
response {}

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-profile-userid-displayname)
//! [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-profile-userid-displayname)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
@ -14,12 +14,13 @@ ruma_api! {
}
request {
/// The new display name for the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>,
/// The user whose display name will be set.
#[ruma_api(path)]
pub user_id: UserId,
/// The new display name for the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>,
}
response {}

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid)
//! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid)
use std::convert::TryFrom;
@ -17,15 +17,17 @@ ruma_api! {
}
request {
/// The event ID to acknowledge up to.
#[ruma_api(path)]
pub event_id: EventId,
/// The type of receipt to send.
#[ruma_api(path)]
pub receipt_type: ReceiptType,
/// The room in which to send the event.
#[ruma_api(path)]
pub room_id: RoomId,
/// The type of receipt to send.
#[ruma_api(path)]
pub receipt_type: ReceiptType,
/// The event ID to acknowledge up to.
#[ruma_api(path)]
pub event_id: EventId,
}
response {}

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid)
//! [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid)
use ruma_api::ruma_api;
use ruma_identifiers::{EventId, RoomId};
@ -14,20 +14,23 @@ ruma_api! {
}
request {
/// The ID of the event to redact.
#[ruma_api(path)]
pub event_id: EventId,
/// The reason for the redaction.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
/// The ID of the room of the event to redact.
#[ruma_api(path)]
pub room_id: RoomId,
/// The ID of the event to redact.
#[ruma_api(path)]
pub event_id: EventId,
/// The transaction ID for this event.
///
/// Clients should generate a unique ID; it will be used by the server to ensure idempotency of requests.
#[ruma_api(path)]
pub txn_id: String,
/// The reason for the redaction.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
response {

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/search](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-search)
//! [POST /_matrix/client/r0/search](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-search)
use std::collections::BTreeMap;
@ -29,6 +29,7 @@ ruma_api! {
/// If given, this should be a `next_batch` result from a previous call to this endpoint.
#[ruma_api(query)]
pub next_batch: Option<String>,
/// Describes which categories to search in and their criteria.
pub search_categories: Categories,
}
@ -52,57 +53,85 @@ pub struct Categories {
/// Criteria for searching a category of events.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Criteria {
/// Configures whether any context for the events returned are included in the response.
/// The string to search events for.
pub search_term: String,
/// The keys to search for. Defaults to all keys.
#[serde(skip_serializing_if = "Option::is_none")]
pub event_context: Option<EventContext>,
pub keys: Option<Vec<SearchKeys>>,
/// A `Filter` to apply to the search.
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<RoomEventFilter>,
/// Requests that the server partitions the result set based on the provided list of keys.
#[serde(skip_serializing_if = "Option::is_none")]
pub groupings: Option<Groupings>,
/// Requests the server return the current state for each room returned.
#[serde(skip_serializing_if = "Option::is_none")]
pub include_state: Option<bool>,
/// The keys to search for. Defaults to all keys.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub keys: Vec<SearchKeys>,
/// The order in which to search for results.
#[serde(skip_serializing_if = "Option::is_none")]
pub order_by: Option<OrderBy>,
/// The string to search events for.
pub search_term: String,
/// Configures whether any context for the events returned are included in the response.
#[serde(skip_serializing_if = "Option::is_none")]
pub event_context: Option<EventContext>,
/// Requests the server return the current state for each room returned.
#[serde(skip_serializing_if = "Option::is_none")]
pub include_state: Option<bool>,
/// Requests that the server partitions the result set based on the provided list of keys.
#[serde(skip_serializing_if = "Option::is_none")]
pub groupings: Option<Groupings>,
}
/// Configures whether any context for the events returned are included in the response.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct EventContext {
/// How many events after the result are returned.
#[serde(skip_serializing_if = "Option::is_none")]
pub after_limit: Option<UInt>,
/// How many events before the result are returned.
#[serde(skip_serializing_if = "Option::is_none")]
pub before_limit: Option<UInt>,
#[serde(
default = "default_event_context_limit",
skip_serializing_if = "is_default_event_context_limit"
)]
pub before_limit: UInt,
/// How many events after the result are returned.
#[serde(
default = "default_event_context_limit",
skip_serializing_if = "is_default_event_context_limit"
)]
pub after_limit: UInt,
/// Requests that the server returns the historic profile information for the users that
/// sent the events that were returned.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
pub include_profile: bool,
}
fn default_event_context_limit() -> UInt {
UInt::from(5u32)
}
#[allow(clippy::trivially_copy_pass_by_ref)]
fn is_default_event_context_limit(val: &UInt) -> bool {
*val == default_event_context_limit()
}
/// Context for search results, if requested.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EventContextResult {
/// Pagination token for the end of the chunk.
#[serde(skip_serializing_if = "Option::is_none")]
pub end: Option<String>,
/// Events just after the result.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub events_after: Vec<EventJson<Event>>,
/// Events just before the result.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub events_before: Vec<EventJson<Event>>,
/// The historic profile information of the users that sent the events returned.
#[serde(skip_serializing_if = "Option::is_none")]
pub profile_info: Option<BTreeMap<UserId, UserProfile>>,
/// Pagination token for the start of the chunk.
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<String>,
@ -121,6 +150,7 @@ pub struct Grouping {
pub enum GroupingKey {
/// `room_id`
RoomId,
/// `sender`
Sender,
}
@ -139,9 +169,11 @@ pub enum SearchKeys {
/// content.body
#[serde(rename = "content.body")]
ContentBody,
/// content.name
#[serde(rename = "content.name")]
ContentName,
/// content.topic
#[serde(rename = "content.topic")]
ContentTopic,
@ -151,11 +183,12 @@ pub enum SearchKeys {
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum OrderBy {
/// Prioritize recent events.
Recent,
/// Prioritize events by a numerical ranking of how closely they matched the search
/// criteria.
Rank,
/// Prioritize recent events.
Recent,
}
/// Categories of events that can be searched for.

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-admin-whois-userid)
//! [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-admin-whois-userid)
use std::{collections::BTreeMap, time::SystemTime};
@ -24,30 +24,22 @@ ruma_api! {
response {
/// The Matrix user ID of the user.
pub user_id: UserId,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<UserId>,
/// A map of the user's device identifiers to information about that device.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub devices: BTreeMap<String, DeviceInfo>,
}
error: crate::Error
}
/// Information about a connection in a user session.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConnectionInfo {
/// Most recently seen IP address of the session.
pub ip: String,
/// Time when that the session was last active.
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
pub last_seen: SystemTime,
/// User agent string last seen in the session.
pub user_agent: String,
}
/// Information about a user's device.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeviceInfo {
/// A list of user sessions on this device.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub sessions: Vec<SessionInfo>,
}
@ -55,5 +47,20 @@ pub struct DeviceInfo {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SessionInfo {
/// A list of connections in this session.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub connections: Vec<ConnectionInfo>,
}
/// Information about a connection in a user session.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConnectionInfo {
/// Most recently seen IP address of the session.
pub ip: Option<String>,
/// Time when that the session was last active.
#[serde(with = "ruma_serde::time::opt_ms_since_unix_epoch")]
pub last_seen: Option<SystemTime>,
/// User agent string last seen in the session.
pub user_agent: Option<String>,
}

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-logout)
//! [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-logout)
use ruma_api::ruma_api;

View File

@ -1,4 +1,4 @@
//! [POST /_matrix/client/r0/logout/all](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-logout-all)
//! [POST /_matrix/client/r0/logout/all](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-logout-all)
use ruma_api::ruma_api;

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state)
//! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state)
use ruma_api::ruma_api;
use ruma_events::{collections::all::StateEvent, EventJson};

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype)
//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state-eventtype)
use ruma_api::ruma_api;
use ruma_events::EventType;
@ -19,6 +19,7 @@ ruma_api! {
/// The room to look up the state for.
#[ruma_api(path)]
pub room_id: RoomId,
/// The type of state to look up.
#[ruma_api(path)]
pub event_type: EventType,

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key)
//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key)
use ruma_api::ruma_api;
use ruma_events::EventType;
@ -19,9 +19,11 @@ ruma_api! {
/// The room to look up the state for.
#[ruma_api(path)]
pub room_id: RoomId,
/// The type of state to look up.
#[ruma_api(path)]
pub event_type: EventType,
/// The key of the state to look up.
#[ruma_api(path)]
pub state_key: String,

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
use ruma_api::ruma_api;
use ruma_events::tag::TagInfo;
@ -15,18 +15,21 @@ ruma_api! {
}
request {
/// The room to tag.
#[ruma_api(path)]
pub room_id: RoomId,
/// The name of the tag to create.
#[ruma_api(path)]
pub tag: String,
/// Info about the tag.
#[ruma_api(body)]
pub tag_info: TagInfo,
/// The ID of the user creating the tag.
#[ruma_api(path)]
pub user_id: UserId,
/// The room to tag.
#[ruma_api(path)]
pub room_id: RoomId,
/// The name of the tag to create.
#[ruma_api(path)]
pub tag: String,
/// Info about the tag.
#[ruma_api(body)]
pub tag_info: TagInfo,
}
response {}

View File

@ -1,4 +1,4 @@
//! [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.4.0.html#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
//! [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.6.0#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, UserId};
@ -14,15 +14,17 @@ ruma_api! {
}
request {
/// The tagged room.
#[ruma_api(path)]
pub room_id: RoomId,
/// The name of the tag to delete.
#[ruma_api(path)]
pub tag: String,
/// The user whose tag will be deleted.
#[ruma_api(path)]
pub user_id: UserId,
/// The tagged room.
#[ruma_api(path)]
pub room_id: RoomId,
/// The name of the tag to delete.
#[ruma_api(path)]
pub tag: String,
}
response {}

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags)
//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-rooms-roomid-tags)
use ruma_api::ruma_api;
use ruma_events::{tag::TagEventContent, EventJson};
@ -15,12 +15,13 @@ ruma_api! {
}
request {
/// The room from which tags will be retrieved.
#[ruma_api(path)]
pub room_id: RoomId,
/// The user whose tags will be retrieved.
#[ruma_api(path)]
pub user_id: UserId,
/// The room from which tags will be retrieved.
#[ruma_api(path)]
pub room_id: RoomId,
}
response {

View File

@ -1,4 +1,4 @@
//! [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-typing-userid)
//! [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-typing-userid)
use std::time::Duration;
@ -16,9 +16,19 @@ ruma_api! {
}
request {
/// The user who has started to type.
#[ruma_api(path)]
pub user_id: UserId,
/// The room in which the user is typing.
#[ruma_api(path)]
pub room_id: RoomId,
// TODO: Group the following two body fields into an enum
/// Whether the user is typing or not. If `false`, the `timeout` key can be omitted.
pub typing: bool,
/// The length of time in milliseconds to mark this user as typing.
#[serde(
with = "ruma_serde::duration::opt_ms",
@ -26,11 +36,6 @@ ruma_api! {
skip_serializing_if = "Option::is_none",
)]
pub timeout: Option<Duration>,
/// Whether the user is typing or not. If `false`, the `timeout` key can be omitted.
pub typing: bool,
/// The user who has started to type.
#[ruma_api(path)]
pub user_id: UserId,
}
response {}

View File

@ -1,4 +1,4 @@
//! [GET /_matrix/client/r0/voip/turnServer](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-voip-turnserver)
//! [GET /_matrix/client/r0/voip/turnServer](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-voip-turnserver)
use std::time::Duration;
@ -17,15 +17,18 @@ ruma_api! {
request {}
response {
/// The username to use.
pub username: String,
/// The password to use.
pub password: String,
/// A list of TURN URIs.
pub uris: Vec<String>,
/// The time-to-live in seconds.
#[serde(with = "ruma_serde::duration::secs")]
pub ttl: Duration,
/// A list of TURN URIs.
pub uris: Vec<String>,
/// The username to use.
pub username: String,
}
error: crate::Error

View File

@ -1,23 +1,9 @@
//! [GET /.well-known/matrix/client](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-well-known-matrix-client)
//! [GET /.well-known/matrix/client](https://matrix.org/docs/spec/client_server/r0.6.0#get-well-known-matrix-client)
use ruma_api::ruma_api;
use serde::{Deserialize, Serialize};
use url::Url;
/// Information about a discovered homeserver.
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
pub struct HomeserverInfo {
/// The base URL for the homeserver for client-server connections.
pub base_url: Url,
}
/// Information about a discovered identity server.
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
pub struct IdentityServerInfo {
/// The base URL for the identity server for client-server connections.
pub base_url: Url,
}
ruma_api! {
metadata {
description: "Get discovery information about the domain.",
@ -42,3 +28,17 @@ ruma_api! {
error: crate::Error
}
/// Information about a discovered homeserver.
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
pub struct HomeserverInfo {
/// The base URL for the homeserver for client-server connections.
pub base_url: Url,
}
/// Information about a discovered identity server.
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
pub struct IdentityServerInfo {
/// The base URL for the identity server for client-server connections.
pub base_url: Url,
}