Merge pull request #20 from jplatte/more-modules
Use ruma-api-macros for more endpoints
This commit is contained in:
commit
ebb05dc076
@ -35,12 +35,12 @@ pub mod r0 {
|
|||||||
// pub mod push;
|
// pub mod push;
|
||||||
// pub mod receipt;
|
// pub mod receipt;
|
||||||
// pub mod redact;
|
// pub mod redact;
|
||||||
// pub mod room;
|
pub mod room;
|
||||||
// pub mod search;
|
// pub mod search;
|
||||||
// pub mod send;
|
pub mod send;
|
||||||
// pub mod server;
|
// pub mod server;
|
||||||
// pub mod session;
|
pub mod session;
|
||||||
// pub mod sync;
|
pub mod sync;
|
||||||
// pub mod tag;
|
// pub mod tag;
|
||||||
// pub mod typing;
|
// pub mod typing;
|
||||||
// pub mod voip;
|
// pub mod voip;
|
||||||
|
@ -24,7 +24,6 @@ pub mod set_room_account_data {
|
|||||||
///
|
///
|
||||||
/// Custom types should be namespaced to avoid clashes.
|
/// Custom types should be namespaced to avoid clashes.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub event_type: String,
|
pub event_type: String,
|
||||||
/// The ID of the room to set account_data on.
|
/// The ID of the room to set account_data on.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -64,7 +63,6 @@ pub mod set_global_account_data {
|
|||||||
///
|
///
|
||||||
/// Custom types should be namespaced to avoid clashes.
|
/// Custom types should be namespaced to avoid clashes.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub event_type: String,
|
pub event_type: String,
|
||||||
/// The ID of the user to set account_data for.
|
/// The ID of the user to set account_data for.
|
||||||
///
|
///
|
||||||
|
@ -3,10 +3,19 @@
|
|||||||
/// [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom)
|
/// [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom)
|
||||||
pub mod create_room {
|
pub mod create_room {
|
||||||
use ruma_identifiers::{RoomId, UserId};
|
use ruma_identifiers::{RoomId, UserId};
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
|
|
||||||
/// The request type.
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub struct BodyParams {
|
description: "Create a new room.",
|
||||||
|
method: Method::Post,
|
||||||
|
name: "create_room",
|
||||||
|
path: "/_matrix/client/r0/createRoom",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
request {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub creation_content: Option<CreationContent>,
|
pub creation_content: Option<CreationContent>,
|
||||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||||
@ -25,6 +34,11 @@ pub mod create_room {
|
|||||||
// TODO: missing `invite_3pid`, `initial_state`
|
// TODO: missing `invite_3pid`, `initial_state`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response {
|
||||||
|
pub room_id: RoomId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Extra options to be added to the `m.room.create` event.
|
/// Extra options to be added to the `m.room.create` event.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct CreationContent {
|
pub struct CreationContent {
|
||||||
@ -33,16 +47,6 @@ pub mod create_room {
|
|||||||
pub federate: Option<bool>,
|
pub federate: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
/// The response type.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub room_id: RoomId,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A convenience parameter for setting a few default state events.
|
/// A convenience parameter for setting a few default state events.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||||
pub enum RoomPreset {
|
pub enum RoomPreset {
|
||||||
@ -56,39 +60,4 @@ pub mod create_room {
|
|||||||
#[serde(rename="trusted_private_chat")]
|
#[serde(rename="trusted_private_chat")]
|
||||||
TrustedPrivateChat,
|
TrustedPrivateChat,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = BodyParams;
|
|
||||||
type PathParams = ();
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Post
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
|
||||||
Self::router_path().to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/createRoom"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"create_room"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Create a new room."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
223
src/r0/send.rs
223
src/r0/send.rs
@ -2,193 +2,118 @@
|
|||||||
|
|
||||||
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype)
|
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype)
|
||||||
pub mod send_state_event_for_empty_key {
|
pub mod send_state_event_for_empty_key {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, EventId};
|
use ruma_identifiers::{RoomId, EventId};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Send a state event to a room associated with the empty state key.",
|
||||||
|
method: Method::Put,
|
||||||
|
name: "send_state_event_for_empty_key",
|
||||||
|
path: "/_matrix/client/r0/rooms/:room_id/state/:event_type",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The room to set the state in.
|
||||||
pub struct PathParams {
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
pub event_type: EventType
|
/// The type of event to send.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub event_type: EventType,
|
||||||
|
/// The event's content.
|
||||||
|
#[ruma_api(body)]
|
||||||
|
pub data: Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's response.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// A unique identifier for the event.
|
||||||
pub struct Response {
|
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ::serde_json::Value;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/state/{}",
|
|
||||||
params.room_id,
|
|
||||||
params.event_type
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"send_state_event_for_empty_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Send a state event to a room associated with the empty state key."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
||||||
pub mod send_state_event_for_key {
|
pub mod send_state_event_for_key {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, EventId};
|
use ruma_identifiers::{RoomId, EventId};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Send a state event to a room associated with a given state key.",
|
||||||
|
method: Method::Put,
|
||||||
|
name: "send_state_event_for_key",
|
||||||
|
path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The room to set the state in.
|
||||||
pub struct PathParams {
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
|
/// The type of event to send.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub event_type: EventType,
|
pub event_type: EventType,
|
||||||
pub state_key: String
|
/// The state_key for the state to send. Defaults to the empty string.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub state_key: String,
|
||||||
|
/// The event's content.
|
||||||
|
#[ruma_api(body)]
|
||||||
|
pub data: Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's response.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// A unique identifier for the event.
|
||||||
pub struct Response {
|
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ::serde_json::Value;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/state/{}/{}",
|
|
||||||
params.room_id,
|
|
||||||
params.event_type,
|
|
||||||
params.state_key
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"send_state_event_for_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Send a state event to a room associated with a given state key."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
/// [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
||||||
pub mod send_message_event {
|
pub mod send_message_event {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, EventId};
|
use ruma_identifiers::{RoomId, EventId};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
|
use ruma_events::room::message::MessageEventContent;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Send a message event to a room.",
|
||||||
|
method: Method::Put,
|
||||||
|
name: "send_message_event",
|
||||||
|
path: "/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The room to send the event to.
|
||||||
pub struct PathParams {
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
|
/// The type of event to send.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub event_type: EventType,
|
pub event_type: EventType,
|
||||||
pub txn_id: String
|
/// The transaction ID for this event.
|
||||||
|
///
|
||||||
|
/// Clients should generate an ID unique across requests with the
|
||||||
|
/// same access token; it will be used by the server to ensure
|
||||||
|
/// idempotency of requests.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub txn_id: String,
|
||||||
|
/// The event's content.
|
||||||
|
#[ruma_api(body)]
|
||||||
|
pub data: MessageEventContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's response.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// A unique identifier for the event.
|
||||||
pub struct Response {
|
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ::serde_json::Value;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/send/{}/{}",
|
|
||||||
params.room_id,
|
|
||||||
params.event_type,
|
|
||||||
params.txn_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"send_message_event"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Send a message event to a room."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,27 +2,18 @@
|
|||||||
|
|
||||||
/// [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login)
|
/// [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login)
|
||||||
pub mod login {
|
pub mod login {
|
||||||
/// Details about this API endpoint.
|
use ruma_api_macros::ruma_api;
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
/// Possible login mediums for 3rd party ID
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub enum LoginMedium {
|
description: "Login to the homeserver.",
|
||||||
#[serde(rename = "email")]
|
method: Method::Post,
|
||||||
Email
|
name: "login",
|
||||||
|
path: "/_matrix/client/r0/login",
|
||||||
|
rate_limited: true,
|
||||||
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
request {
|
||||||
/// Possible kinds of login
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub enum LoginKind {
|
|
||||||
#[serde(rename = "m.login.password")]
|
|
||||||
Password
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The body parameters for this endpoint
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct BodyParams {
|
|
||||||
/// Password of the user
|
/// Password of the user
|
||||||
pub password: String,
|
pub password: String,
|
||||||
/// Medium of 3rd party login to use
|
/// Medium of 3rd party login to use
|
||||||
@ -37,91 +28,44 @@ pub mod login {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub address: Option<String>
|
pub address: Option<String>
|
||||||
}
|
}
|
||||||
|
response {
|
||||||
/// This API endpoint's response.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub access_token: String,
|
pub access_token: String,
|
||||||
pub home_server: String,
|
pub home_server: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub refresh_token: Option<String>,
|
pub refresh_token: Option<String>,
|
||||||
pub user_id: String,
|
pub user_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = ();
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Post
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
/// Possible login mediums for 3rd party ID
|
||||||
Self::router_path().to_string()
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub enum LoginMedium {
|
||||||
|
#[serde(rename = "email")]
|
||||||
|
Email,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
/// Possible kinds of login
|
||||||
"/_matrix/client/r0/login"
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
}
|
pub enum LoginKind {
|
||||||
|
#[serde(rename = "m.login.password")]
|
||||||
fn name() -> &'static str {
|
Password,
|
||||||
"login"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Login to the homeserver."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout)
|
/// [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout)
|
||||||
pub mod logout {
|
pub mod logout {
|
||||||
/// Details about this API endpoint.
|
use ruma_api_macros::ruma_api;
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
ruma_api! {
|
||||||
type BodyParams = ();
|
metadata {
|
||||||
type PathParams = ();
|
description: "Log out of the homeserver.",
|
||||||
type QueryParams = ();
|
method: Method::Post,
|
||||||
type Response = ();
|
name: "logout",
|
||||||
|
path: "/_matrix/client/r0/logout",
|
||||||
fn method() -> ::Method {
|
rate_limited: false,
|
||||||
::Method::Post
|
requires_authentication: true,
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
|
||||||
Self::router_path().to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/logout"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"logout"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Log out of the homeserver."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
request {}
|
||||||
|
response {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
467
src/r0/sync.rs
467
src/r0/sync.rs
@ -2,247 +2,159 @@
|
|||||||
|
|
||||||
/// [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state)
|
/// [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state)
|
||||||
pub mod get_state_events {
|
pub mod get_state_events {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use ruma_events::collections::only;
|
use ruma_events::collections::only;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Get state events for a room.",
|
||||||
|
method: Method::Get,
|
||||||
/// This API endpoint's path parameters.
|
name: "get_state_events",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/state",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
pub room_id: RoomId
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
request {
|
||||||
impl ::Endpoint for Endpoint {
|
#[ruma_api(path)]
|
||||||
type BodyParams = ();
|
pub room_id: RoomId,
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Vec<only::StateEvent>;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
}
|
||||||
|
response {
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
pub room_state: Vec<only::StateEvent>,
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/state",
|
|
||||||
params.room_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/state"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_state_events"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get state events for a room."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.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.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype)
|
||||||
pub mod get_state_events_for_empty_key {
|
pub mod get_state_events_for_empty_key {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
|
use ruma_events::EventType;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Get state events of a given type associated with the empty key.",
|
||||||
|
method: Method::Get,
|
||||||
/// This API endpoint's path parameters.
|
name: "get_state_events_for_empty_key",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/state/:event_type",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
request {
|
||||||
|
/// The room to query for events
|
||||||
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
pub event_type: String
|
/// The type of state to look up
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub event_type: EventType,
|
||||||
}
|
}
|
||||||
|
response {
|
||||||
impl ::Endpoint for Endpoint {
|
pub content: ::serde_json::Value,
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = ::serde_json::Value;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/state/{}",
|
|
||||||
params.room_id,
|
|
||||||
params.event_type
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_state_events_for_empty_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get state events of a given type associated with the empty key."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.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.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key)
|
||||||
pub mod get_state_events_for_key {
|
pub mod get_state_events_for_key {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Get state events associated with a given key.",
|
||||||
|
method: Method::Get,
|
||||||
/// This API endpoint's path parameters.
|
name: "get_state_events_for_key",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
request {
|
||||||
|
/// The room to look up the state in.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
|
/// The type of state to look up.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub event_type: String,
|
pub event_type: String,
|
||||||
|
/// The key of the state to look up.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub state_key: String,
|
pub state_key: String,
|
||||||
}
|
}
|
||||||
|
response {
|
||||||
impl ::Endpoint for Endpoint {
|
pub content: ::serde_json::Value,
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = ::serde_json::Value;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/state/{}/{}",
|
|
||||||
params.room_id,
|
|
||||||
params.event_type,
|
|
||||||
params.state_key
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_state_events_for_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get state events associated with a given key."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-members)
|
/// [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-members)
|
||||||
pub mod get_member_events {
|
pub mod get_member_events {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use ruma_events::room::member::MemberEvent;
|
use ruma_events::room::member::MemberEvent;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Get membership events for a room.",
|
||||||
|
method: Method::Get,
|
||||||
/// This API endpoint's path parameters.
|
name: "get_member_events",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/members",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
pub room_id: RoomId,
|
requires_authentication: false,
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's reponse.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub chunk: Vec<MemberEvent>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/members",
|
|
||||||
params.room_id,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/members"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_member_events"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get membership events for a room."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
// TODO: not marked as requiring auth in the spec, but
|
// TODO: not marked as requiring auth in the spec, but
|
||||||
// will return a 403 error is user is not a member of the
|
// will return a 403 error is user is not a member of the
|
||||||
// room anyway...
|
// room anyway...
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
request {
|
||||||
fn rate_limited() -> bool {
|
/// The room to look up the state in.
|
||||||
false
|
#[ruma_api(path)]
|
||||||
|
pub room_id: RoomId,
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
pub chunk: Vec<MemberEvent>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages)
|
/// [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages)
|
||||||
pub mod get_message_events {
|
pub mod get_message_events {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use ruma_events::collections::only;
|
use ruma_events::collections::only;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Get message events for a room.",
|
||||||
|
method: Method::Get,
|
||||||
/// This API endpoint's path parameters.
|
name: "get_message_events",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/messages",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
request {
|
||||||
|
// NOTE: The non-macro version of this call included two path params, where the spec only
|
||||||
|
// has one, room_id. I've followed the spec here. -- rschulman 6/30/2017
|
||||||
|
/// The room to look up the state in.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
pub event_type: String
|
/// Required. The token to start returning events from. This token can be obtained from a
|
||||||
|
/// prev_batch token returned for each room by the sync API, or from a start or end token
|
||||||
|
/// returned by a previous request to this endpoint.
|
||||||
|
pub from: String,
|
||||||
|
/// The token to stop returning events at. This token can be obtained from a prev_batch
|
||||||
|
/// token returned for each room by the sync endpoint, or from a start or end token returned
|
||||||
|
/// by a previous request to this endpoint.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub to: Option<String>,
|
||||||
|
/// Required. The direction to return events from. One of: ["b", "f"]
|
||||||
|
pub dir: Direction,
|
||||||
|
/// The maximum number of events to return. Default: 10.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub limit: Option<u64>,
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
pub start: String,
|
||||||
|
pub chunk: Vec<only::RoomEvent>,
|
||||||
|
pub end: String,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
@ -250,69 +162,13 @@ pub mod get_message_events {
|
|||||||
#[serde(rename="b")]
|
#[serde(rename="b")]
|
||||||
Backward,
|
Backward,
|
||||||
#[serde(rename="f")]
|
#[serde(rename="f")]
|
||||||
Forward
|
Forward,
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's query string parameters.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct QueryParams {
|
|
||||||
pub from: String,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub to: Option<String>,
|
|
||||||
pub dir: Direction,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub limit: Option<u64>
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's reponse.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub start: String,
|
|
||||||
pub chunk: Vec<only::RoomEvent>,
|
|
||||||
pub end: String
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = QueryParams;
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/rooms/{}/messages",
|
|
||||||
params.room_id,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/rooms/:room_id/messages"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_message_events"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get message events for a room."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/sync](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync)
|
/// [GET /_matrix/client/r0/sync](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync)
|
||||||
pub mod sync_events {
|
pub mod sync_events {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_events::collections::only;
|
use ruma_events::collections::only;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
|
|
||||||
@ -320,15 +176,40 @@ pub mod sync_events {
|
|||||||
|
|
||||||
use r0::filter::FilterDefinition;
|
use r0::filter::FilterDefinition;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Get all new events from all rooms since the last sync or a given point of time.",
|
||||||
|
method: Method::Get,
|
||||||
|
name: "sync",
|
||||||
|
path: "/_matrix/client/r0/sync",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
request {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub filter: Option<Filter>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub since: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub full_state: Option<bool>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub set_presence: Option<SetPresence>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub timeout: Option<u64>,
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
pub next_batch: String,
|
||||||
|
pub rooms: Rooms,
|
||||||
|
pub presence: Presence,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether to set presence or not during sync.
|
/// Whether to set presence or not during sync.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub enum SetPresence {
|
pub enum SetPresence {
|
||||||
#[serde(rename="offline")]
|
#[serde(rename="offline")]
|
||||||
Offline
|
Offline,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
||||||
@ -340,34 +221,19 @@ pub mod sync_events {
|
|||||||
FilterId(String),
|
FilterId(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's query string parameters.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct QueryParams {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub filter: Option<Filter>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub since: Option<String>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub full_state: Option<bool>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub set_presence: Option<SetPresence>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub timeout: Option<u64>
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Updates to rooms
|
/// Updates to rooms
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Rooms {
|
pub struct Rooms {
|
||||||
pub leave: HashMap<RoomId, LeftRoom>,
|
pub leave: HashMap<RoomId, LeftRoom>,
|
||||||
pub join: HashMap<RoomId, JoinedRoom>,
|
pub join: HashMap<RoomId, JoinedRoom>,
|
||||||
pub invite: HashMap<RoomId, InvitedRoom>
|
pub invite: HashMap<RoomId, InvitedRoom>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Historical updates to left rooms
|
/// Historical updates to left rooms
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct LeftRoom {
|
pub struct LeftRoom {
|
||||||
pub timeline: Timeline,
|
pub timeline: Timeline,
|
||||||
pub state: State
|
pub state: State,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates to joined rooms
|
/// Updates to joined rooms
|
||||||
@ -377,14 +243,14 @@ pub mod sync_events {
|
|||||||
pub timeline: Timeline,
|
pub timeline: Timeline,
|
||||||
pub state: State,
|
pub state: State,
|
||||||
pub account_data: AccountData,
|
pub account_data: AccountData,
|
||||||
pub ephemeral: Ephemeral
|
pub ephemeral: Ephemeral,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// unread notifications count
|
/// unread notifications count
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct UnreadNotificationsCount {
|
pub struct UnreadNotificationsCount {
|
||||||
pub highlight_count: u64,
|
pub highlight_count: u64,
|
||||||
pub notification_count: u64
|
pub notification_count: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// timeline
|
/// timeline
|
||||||
@ -392,85 +258,42 @@ pub mod sync_events {
|
|||||||
pub struct Timeline {
|
pub struct Timeline {
|
||||||
pub limited: bool,
|
pub limited: bool,
|
||||||
pub prev_batch: String,
|
pub prev_batch: String,
|
||||||
pub events: only::RoomEvent
|
pub events: only::RoomEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// state
|
/// state
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub events: only::StateEvent
|
pub events: only::StateEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// account data
|
/// account data
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct AccountData {
|
pub struct AccountData {
|
||||||
pub events: only::Event
|
pub events: only::Event,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ephemeral
|
/// ephemeral
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Ephemeral {
|
pub struct Ephemeral {
|
||||||
pub events: only::Event
|
pub events: only::Event,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// invited room updates
|
/// invited room updates
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct InvitedRoom {
|
pub struct InvitedRoom {
|
||||||
pub invite_state: InviteState
|
pub invite_state: InviteState,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// invite state
|
/// invite state
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct InviteState {
|
pub struct InviteState {
|
||||||
pub events: only::StateEvent
|
pub events: only::StateEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// presence
|
/// presence
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Presence {
|
pub struct Presence {
|
||||||
pub events: only::Event
|
pub events: only::Event,
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's reponse.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub next_batch: String,
|
|
||||||
pub rooms: Rooms,
|
|
||||||
pub presence: Presence
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = ();
|
|
||||||
type QueryParams = QueryParams;
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
|
||||||
"/_matrix/client/r0/sync".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/sync"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"sync"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get all new events from all rooms since the last sync or a given point of time."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user