Update ruma-api, restore request receiving / response sending support
This commit is contained in:
parent
6e665efd1c
commit
e30c82d248
@ -14,7 +14,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
js_int = { version = "0.1.2", features = ["serde"] }
|
||||
ruma-api = "0.11.2"
|
||||
ruma-api = "0.12.0-alpha.1"
|
||||
ruma-events = "0.15.1"
|
||||
ruma-identifiers = "0.14.0"
|
||||
serde = { version = "1.0.102", features = ["derive"] }
|
||||
|
@ -32,16 +32,20 @@ ruma_api! {
|
||||
/// A token that can be used to paginate forwards with.
|
||||
pub end: String,
|
||||
/// Details of the requested event.
|
||||
pub event: EventResult<only::RoomEvent>,
|
||||
#[wrap_incoming(with EventResult)]
|
||||
pub event: only::RoomEvent,
|
||||
/// A list of room events that happened just after the requested event, in chronological
|
||||
/// order.
|
||||
pub events_after: Vec<EventResult<only::RoomEvent>>,
|
||||
#[wrap_incoming(only::RoomEvent with EventResult)]
|
||||
pub events_after: Vec<only::RoomEvent>,
|
||||
/// A list of room events that happened just before the requested event, in
|
||||
/// reverse-chronological order.
|
||||
pub events_before: Vec<EventResult<only::RoomEvent>>,
|
||||
#[wrap_incoming(only::RoomEvent with EventResult)]
|
||||
pub events_before: Vec<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.
|
||||
pub state: Vec<EventResult<only::StateEvent>>,
|
||||
#[wrap_incoming(only::StateEvent with EventResult)]
|
||||
pub state: Vec<only::StateEvent>,
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ ruma_api! {
|
||||
response {
|
||||
/// A list of presence events for every user on this list.
|
||||
#[ruma_api(body)]
|
||||
pub presence_events: Vec<EventResult<PresenceEvent>>,
|
||||
#[wrap_incoming(PresenceEvent with EventResult)]
|
||||
pub presence_events: Vec<PresenceEvent>,
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_api::{ruma_api, Outgoing};
|
||||
use ruma_events::{collections::all::Event, EventResult};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -32,6 +32,7 @@ ruma_api! {
|
||||
|
||||
response {
|
||||
/// A grouping of search results by category.
|
||||
#[wrap_incoming]
|
||||
pub search_categories: ResultCategories,
|
||||
}
|
||||
}
|
||||
@ -84,16 +85,18 @@ pub struct EventContext {
|
||||
}
|
||||
|
||||
/// Context for search results, if requested.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct EventContextResult {
|
||||
/// Pagination token for the end of the chunk.
|
||||
pub end: String,
|
||||
/// Events just after the result.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub events_after: Option<Vec<EventResult<Event>>>,
|
||||
#[wrap_incoming(Event with EventResult)]
|
||||
pub events_after: Option<Vec<Event>>,
|
||||
/// Events just before the result.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub events_before: Option<Vec<EventResult<Event>>>,
|
||||
#[wrap_incoming(Event with EventResult)]
|
||||
pub events_before: Option<Vec<Event>>,
|
||||
/// The historic profile information of the users that sent the events returned.
|
||||
// TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -152,15 +155,16 @@ pub enum OrderBy {
|
||||
}
|
||||
|
||||
/// Categories of events that can be searched for.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct ResultCategories {
|
||||
/// Room event results.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[wrap_incoming(RoomEventResults)]
|
||||
pub room_events: Option<RoomEventResults>,
|
||||
}
|
||||
|
||||
/// Categories of events that can be searched for.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct RoomEventResults {
|
||||
/// An approximate count of the total number of results found.
|
||||
pub count: UInt,
|
||||
@ -172,6 +176,7 @@ pub struct RoomEventResults {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub next_batch: Option<String>,
|
||||
/// List of results in the requested order.
|
||||
#[wrap_incoming(SearchResult)]
|
||||
pub results: Vec<SearchResult>,
|
||||
/// The current state for every room in the results. This is included if the request had the
|
||||
/// `include_state` key set with a value of `true`.
|
||||
@ -195,15 +200,17 @@ pub struct ResultGroup {
|
||||
}
|
||||
|
||||
/// A search result.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct SearchResult {
|
||||
/// Context for result, if requested.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[wrap_incoming(EventContextResult)]
|
||||
pub context: Option<EventContextResult>,
|
||||
/// A number that describes how closely this result matches the search. Higher is closer.
|
||||
pub rank: f64,
|
||||
/// The event that matched.
|
||||
pub result: EventResult<Event>,
|
||||
#[wrap_incoming(with EventResult)]
|
||||
pub result: Event,
|
||||
}
|
||||
|
||||
/// A user profile.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{room::message::MessageEventContent, EventType};
|
||||
use ruma_events::{room::message::MessageEventContent, EventResult, EventType};
|
||||
use ruma_identifiers::{EventId, RoomId};
|
||||
|
||||
ruma_api! {
|
||||
@ -30,6 +30,7 @@ ruma_api! {
|
||||
pub txn_id: String,
|
||||
/// The event's content.
|
||||
#[ruma_api(body)]
|
||||
#[wrap_incoming(with EventResult)]
|
||||
pub data: MessageEventContent,
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ ruma_api! {
|
||||
|
||||
response {
|
||||
/// A list of member events.
|
||||
pub chunk: Vec<EventResult<MemberEvent>>
|
||||
#[wrap_incoming(MemberEvent with EventResult)]
|
||||
pub chunk: Vec<MemberEvent>
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ ruma_api! {
|
||||
/// The token the pagination starts from.
|
||||
pub start: String,
|
||||
/// A list of room events.
|
||||
pub chunk: Vec<EventResult<only::RoomEvent>>,
|
||||
#[wrap_incoming(only::RoomEvent with EventResult)]
|
||||
pub chunk: Vec<only::RoomEvent>,
|
||||
/// The token the pagination ends at.
|
||||
pub end: String,
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ ruma_api! {
|
||||
/// list of events. If the user has left the room then this will be the state of the
|
||||
/// room when they left as a list of events.
|
||||
#[ruma_api(body)]
|
||||
pub room_state: Vec<EventResult<only::StateEvent>>,
|
||||
#[wrap_incoming(only::StateEvent with EventResult)]
|
||||
pub room_state: Vec<only::StateEvent>,
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_api::{ruma_api, Outgoing};
|
||||
use ruma_events::{
|
||||
collections::{all, only},
|
||||
stripped, EventResult,
|
||||
@ -50,11 +50,12 @@ ruma_api! {
|
||||
/// The batch token to supply in the `since` param of the next `/sync` request.
|
||||
pub next_batch: String,
|
||||
/// Updates to rooms.
|
||||
#[wrap_incoming]
|
||||
pub rooms: Rooms,
|
||||
/// Updates to the presence status of other users.
|
||||
#[wrap_incoming]
|
||||
pub presence: Presence,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Whether to set presence or not during sync.
|
||||
@ -114,41 +115,50 @@ mod filter_def_serde {
|
||||
}
|
||||
|
||||
/// Updates to rooms.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct Rooms {
|
||||
/// The rooms that the user has left or been banned from.
|
||||
#[wrap_incoming(LeftRoom)]
|
||||
pub leave: HashMap<RoomId, LeftRoom>,
|
||||
/// The rooms that the user has joined.
|
||||
#[wrap_incoming(JoinedRoom)]
|
||||
pub join: HashMap<RoomId, JoinedRoom>,
|
||||
/// The rooms that the user has been invited to.
|
||||
#[wrap_incoming(InvitedRoom)]
|
||||
pub invite: HashMap<RoomId, InvitedRoom>,
|
||||
}
|
||||
|
||||
/// Historical updates to left rooms.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct LeftRoom {
|
||||
/// The timeline of messages and state changes in the room up to the point when the user
|
||||
/// left.
|
||||
#[wrap_incoming]
|
||||
pub timeline: Timeline,
|
||||
/// The state updates for the room up to the start of the timeline.
|
||||
#[wrap_incoming]
|
||||
pub state: State,
|
||||
}
|
||||
|
||||
/// Updates to joined rooms.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct JoinedRoom {
|
||||
/// Counts of unread notifications for this room.
|
||||
pub unread_notifications: UnreadNotificationsCount,
|
||||
/// The timeline of messages and state changes in the room.
|
||||
#[wrap_incoming]
|
||||
pub timeline: Timeline,
|
||||
/// Updates to the state, between the time indicated by the `since` parameter, and the start
|
||||
/// of the `timeline` (or all state up to the start of the `timeline`, if `since` is not
|
||||
/// given, or `full_state` is true).
|
||||
#[wrap_incoming]
|
||||
pub state: State,
|
||||
/// The private data that this user has attached to this room.
|
||||
#[wrap_incoming]
|
||||
pub account_data: AccountData,
|
||||
/// The ephemeral events in the room that aren't recorded in the timeline or state of the
|
||||
/// room. e.g. typing.
|
||||
#[wrap_incoming]
|
||||
pub ephemeral: Ephemeral,
|
||||
}
|
||||
|
||||
@ -164,7 +174,7 @@ pub struct UnreadNotificationsCount {
|
||||
}
|
||||
|
||||
/// Events in the room.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct Timeline {
|
||||
/// True if the number of events returned was limited by the `limit` on the filter.
|
||||
pub limited: bool,
|
||||
@ -172,47 +182,54 @@ pub struct Timeline {
|
||||
/// `/rooms/{roomId}/messages` endpoint.
|
||||
pub prev_batch: String,
|
||||
/// A list of events.
|
||||
pub events: Vec<EventResult<all::RoomEvent>>,
|
||||
#[wrap_incoming(all::RoomEvent with EventResult)]
|
||||
pub events: Vec<all::RoomEvent>,
|
||||
}
|
||||
|
||||
/// State events in the room.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct State {
|
||||
/// A list of state events.
|
||||
pub events: Vec<EventResult<only::StateEvent>>,
|
||||
#[wrap_incoming(only::StateEvent with EventResult)]
|
||||
pub events: Vec<only::StateEvent>,
|
||||
}
|
||||
|
||||
/// The private data that this user has attached to this room.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct AccountData {
|
||||
/// A list of events.
|
||||
pub events: Vec<EventResult<only::Event>>,
|
||||
#[wrap_incoming(only::Event with EventResult)]
|
||||
pub events: Vec<only::Event>,
|
||||
}
|
||||
|
||||
/// Ephemeral events not recorded in the timeline or state of the room.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct Ephemeral {
|
||||
/// A list of events.
|
||||
pub events: Vec<EventResult<only::Event>>,
|
||||
#[wrap_incoming(only::Event with EventResult)]
|
||||
pub events: Vec<only::Event>,
|
||||
}
|
||||
|
||||
/// Updates to the rooms that the user has been invited to.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct InvitedRoom {
|
||||
/// The state of a room that the user has been invited to.
|
||||
#[wrap_incoming]
|
||||
pub invite_state: InviteState,
|
||||
}
|
||||
|
||||
/// The state of a room that the user has been invited to.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct InviteState {
|
||||
/// A list of state events.
|
||||
pub events: Vec<EventResult<stripped::StrippedState>>,
|
||||
#[wrap_incoming(stripped::StrippedState with EventResult)]
|
||||
pub events: Vec<stripped::StrippedState>,
|
||||
}
|
||||
|
||||
/// Updates to the presence status of other users.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Outgoing)]
|
||||
pub struct Presence {
|
||||
/// A list of events.
|
||||
pub events: Vec<EventResult<only::Event>>,
|
||||
#[wrap_incoming(only::Event with EventResult)]
|
||||
pub events: Vec<only::Event>,
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ ruma_api! {
|
||||
|
||||
response {
|
||||
/// The user's tags for the room.
|
||||
pub tags: EventResult<TagEventContent>,
|
||||
#[wrap_incoming(with EventResult)]
|
||||
pub tags: TagEventContent,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user