client-api: add rooms/initialSync support
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
f674006487
commit
8cade7a14f
@ -6,6 +6,7 @@ pub mod get_event_by_timestamp;
|
||||
pub mod get_room_event;
|
||||
#[cfg(feature = "unstable-msc3266")]
|
||||
pub mod get_summary;
|
||||
pub mod initial_sync;
|
||||
pub mod report_content;
|
||||
pub mod report_room;
|
||||
pub mod upgrade_room;
|
||||
|
94
crates/ruma-client-api/src/room/initial_sync.rs
Normal file
94
crates/ruma-client-api/src/room/initial_sync.rs
Normal file
@ -0,0 +1,94 @@
|
||||
//! `GET /_matrix/client/*/rooms/{roomId}/initialSync`
|
||||
//!
|
||||
//! DEPRECATED
|
||||
|
||||
pub mod v3 {
|
||||
//! `/v3/` ([spec])
|
||||
//!
|
||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3roomsroomidinitialsync
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
OwnedRoomId,
|
||||
};
|
||||
use ruma_events::{
|
||||
room::member::MembershipState, AnyRoomAccountDataEvent, AnyStateEvent, AnyTimelineEvent,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::room::Visibility;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
rate_limited: false,
|
||||
authentication: AccessToken,
|
||||
history: {
|
||||
1.0 => "/_matrix/client/r0/rooms/:room_id/initialSync",
|
||||
1.1 => "/_matrix/client/v3/rooms/:room_id/initialSync",
|
||||
}
|
||||
};
|
||||
|
||||
/// Request type for the `get_room_event` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request {
|
||||
/// The ID of the room.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// Limit messages chunks size
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub limit: Option<usize>,
|
||||
}
|
||||
|
||||
/// Response type for the `get_room_event` endpoint.
|
||||
#[response(error = crate::Error)]
|
||||
pub struct Response {
|
||||
/// The private data that this user has attached to this room.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub account_data: Option<Vec<Raw<AnyRoomAccountDataEvent>>>,
|
||||
|
||||
/// The user’s membership state in this room. One of: [invite, join, leave, ban].
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub membership: Option<MembershipState>,
|
||||
|
||||
/// The pagination chunk for this room.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub messages: Option<PaginationChunk>,
|
||||
|
||||
/// The ID of this room.
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// If the user is a member of the room this will be the current state of the room as a
|
||||
/// list of events. If the user has left the room this will be the state of the room when
|
||||
/// they left it.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub state: Option<Vec<Raw<AnyStateEvent>>>,
|
||||
|
||||
/// Whether this room is visible to the /publicRooms API or not.
|
||||
/// One of: [private, public].
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub visibility: Option<Visibility>,
|
||||
}
|
||||
|
||||
/// Page of timeline events
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct PaginationChunk {
|
||||
/// If the user is a member of the room this will be a list of the most recent messages
|
||||
/// for this room. If the user has left the room this will be the messages that preceded
|
||||
/// them leaving. This array will consist of at most limit elements.
|
||||
pub chunk: Vec<Raw<AnyTimelineEvent>>,
|
||||
|
||||
/// A token which correlates to the end of chunk. Can be passed to
|
||||
/// /rooms/<room_id>/messages to retrieve later events.
|
||||
pub end: String,
|
||||
|
||||
/// A token which correlates to the start of chunk. Can be passed to
|
||||
/// /rooms/<room_id>/messages to retrieve earlier events. If no earlier events are
|
||||
/// available, this property may be omitted from the response.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub start: Option<String>,
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user