Remove borrowing in requests
This commit is contained in:
parent
61a9d65b71
commit
3211fccab0
@ -213,57 +213,6 @@ guidelines:
|
|||||||
- If you're not sure what to name it, pick any name and we can help you
|
- If you're not sure what to name it, pick any name and we can help you
|
||||||
with it.
|
with it.
|
||||||
|
|
||||||
### Borrowing Request Types
|
|
||||||
|
|
||||||
In order to reduce the number of `.clone()`s necessary to send requests
|
|
||||||
to a server, we support borrowed types for request types. (We hope to support
|
|
||||||
borrowing in response types sometime, but that is dependent on GATs.)
|
|
||||||
|
|
||||||
#### Types to borrow
|
|
||||||
|
|
||||||
| Field type | Borrowed type | Notes |
|
|
||||||
| ---------- | ------------- | ----- |
|
|
||||||
| strings | `&'a str` | |
|
|
||||||
| identifiers | `&'a IdentifierType` | |
|
|
||||||
| `Vec<_>` | `&'a [_]` | The inner type should not be borrowed. |
|
|
||||||
|
|
||||||
#### Types not to borrow
|
|
||||||
|
|
||||||
Inner types of `Vec`s _should not_ be borrowed, nor should `BTreeMap`s and such.
|
|
||||||
|
|
||||||
Structs also should not be borrowed, with the exception that if a struct:
|
|
||||||
|
|
||||||
- has fields that should be borrowed according to the table
|
|
||||||
above (strings, identifiers, `Vec`s), and
|
|
||||||
- is only used inside request blocks (i.e. not in response blocks or in events),
|
|
||||||
|
|
||||||
then the struct should be lifetime-parameterized and apply the same rules to
|
|
||||||
their fields. So instead of
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#[request]
|
|
||||||
pub struct Request {
|
|
||||||
my_field: MyStruct,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MyStruct {
|
|
||||||
inner_string_field: String,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
use
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#[request]
|
|
||||||
pub struct Request<'a> {
|
|
||||||
my_field: MyStruct<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MyStruct<'a> {
|
|
||||||
inner_string_field: &'a str,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Tracking Changes
|
### Tracking Changes
|
||||||
|
|
||||||
If your changes affect the API of a user-facing crate (all except the `-macros` crates and
|
If your changes affect the API of a user-facing crate (all except the `-macros` crates and
|
||||||
|
@ -21,7 +21,7 @@ pub mod v1 {
|
|||||||
events::AnyTimelineEvent,
|
events::AnyTimelineEvent,
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
OwnedTransactionId, TransactionId,
|
OwnedTransactionId,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "unstable-msc2409")]
|
#[cfg(feature = "unstable-msc2409")]
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
@ -48,15 +48,15 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `push_events` endpoint.
|
/// Request type for the `push_events` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The transaction ID for this set of events.
|
/// The transaction ID for this set of events.
|
||||||
///
|
///
|
||||||
/// Homeservers generate these IDs and they are used to ensure idempotency of results.
|
/// Homeservers generate these IDs and they are used to ensure idempotency of results.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub txn_id: &'a TransactionId,
|
pub txn_id: OwnedTransactionId,
|
||||||
|
|
||||||
/// A list of events.
|
/// A list of events.
|
||||||
pub events: &'a [Raw<AnyTimelineEvent>],
|
pub events: Vec<Raw<AnyTimelineEvent>>,
|
||||||
|
|
||||||
/// Information on E2E device updates.
|
/// Information on E2E device updates.
|
||||||
#[cfg(feature = "unstable-msc3202")]
|
#[cfg(feature = "unstable-msc3202")]
|
||||||
@ -96,7 +96,7 @@ pub mod v1 {
|
|||||||
skip_serializing_if = "<[_]>::is_empty",
|
skip_serializing_if = "<[_]>::is_empty",
|
||||||
rename = "de.sorunome.msc2409.ephemeral"
|
rename = "de.sorunome.msc2409.ephemeral"
|
||||||
)]
|
)]
|
||||||
pub ephemeral: &'a [Edu],
|
pub ephemeral: Vec<Edu>,
|
||||||
|
|
||||||
/// A list of to-device messages.
|
/// A list of to-device messages.
|
||||||
#[cfg(feature = "unstable-msc2409")]
|
#[cfg(feature = "unstable-msc2409")]
|
||||||
@ -105,7 +105,7 @@ pub mod v1 {
|
|||||||
skip_serializing_if = "<[_]>::is_empty",
|
skip_serializing_if = "<[_]>::is_empty",
|
||||||
rename = "de.sorunome.msc2409.to_device"
|
rename = "de.sorunome.msc2409.to_device"
|
||||||
)]
|
)]
|
||||||
pub to_device: &'a [Raw<AnyToDeviceEvent>],
|
pub to_device: Vec<Raw<AnyToDeviceEvent>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `push_events` endpoint.
|
/// Response type for the `push_events` endpoint.
|
||||||
@ -113,33 +113,10 @@ pub mod v1 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given transaction ID and list of events.
|
/// Creates an `Request` with the given transaction ID and list of events.
|
||||||
pub fn new(txn_id: &'a TransactionId, events: &'a [Raw<AnyTimelineEvent>]) -> Self {
|
pub fn new(txn_id: OwnedTransactionId, events: Vec<Raw<AnyTimelineEvent>>) -> Request {
|
||||||
Self {
|
Request {
|
||||||
txn_id,
|
|
||||||
events,
|
|
||||||
#[cfg(feature = "unstable-msc3202")]
|
|
||||||
device_lists: DeviceLists::new(),
|
|
||||||
#[cfg(feature = "unstable-msc3202")]
|
|
||||||
device_one_time_keys_count: BTreeMap::new(),
|
|
||||||
#[cfg(feature = "unstable-msc3202")]
|
|
||||||
device_unused_fallback_key_types: BTreeMap::new(),
|
|
||||||
#[cfg(feature = "unstable-msc2409")]
|
|
||||||
ephemeral: &[],
|
|
||||||
#[cfg(feature = "unstable-msc2409")]
|
|
||||||
to_device: &[],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IncomingRequest {
|
|
||||||
/// Creates an `IncomingRequest` with the given transaction ID and list of events.
|
|
||||||
pub fn new(
|
|
||||||
txn_id: OwnedTransactionId,
|
|
||||||
events: Vec<Raw<AnyTimelineEvent>>,
|
|
||||||
) -> IncomingRequest {
|
|
||||||
IncomingRequest {
|
|
||||||
txn_id,
|
txn_id,
|
||||||
events,
|
events,
|
||||||
#[cfg(feature = "unstable-msc3202")]
|
#[cfg(feature = "unstable-msc3202")]
|
||||||
@ -393,7 +370,7 @@ pub mod v1 {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let events = vec![dummy_event];
|
let events = vec![dummy_event];
|
||||||
|
|
||||||
let req = Request::new("any_txn_id".into(), &events)
|
let req = Request::new("any_txn_id".into(), events)
|
||||||
.try_into_http_request::<Vec<u8>>(
|
.try_into_http_request::<Vec<u8>>(
|
||||||
"https://homeserver.tld",
|
"https://homeserver.tld",
|
||||||
SendAccessToken::IfRequired("auth_tok"),
|
SendAccessToken::IfRequired("auth_tok"),
|
||||||
|
@ -9,7 +9,7 @@ pub mod v1 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomAliasId,
|
metadata, OwnedRoomAliasId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -23,10 +23,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `query_room_alias` endpoint.
|
/// Request type for the `query_room_alias` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room alias being queried.
|
/// The room alias being queried.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_alias: &'a RoomAliasId,
|
pub room_alias: OwnedRoomAliasId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `query_room_alias` endpoint.
|
/// Response type for the `query_room_alias` endpoint.
|
||||||
@ -34,9 +34,9 @@ pub mod v1 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room alias.
|
/// Creates a new `Request` with the given room alias.
|
||||||
pub fn new(room_alias: &'a RoomAliasId) -> Self {
|
pub fn new(room_alias: OwnedRoomAliasId) -> Self {
|
||||||
Self { room_alias }
|
Self { room_alias }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v1 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, UserId,
|
metadata, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -23,10 +23,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `query_user_id` endpoint.
|
/// Request type for the `query_user_id` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user ID being queried.
|
/// The user ID being queried.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `query_user_id` endpoint.
|
/// Response type for the `query_user_id` endpoint.
|
||||||
@ -34,9 +34,9 @@ pub mod v1 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user id.
|
/// Creates a new `Request` with the given user id.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `get_location_for_protocol` endpoint.
|
/// Request type for the `get_location_for_protocol` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The protocol used to communicate to the third party network.
|
/// The protocol used to communicate to the third party network.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub protocol: &'a str,
|
pub protocol: String,
|
||||||
|
|
||||||
/// One or more custom fields to help identify the third party location.
|
/// One or more custom fields to help identify the third party location.
|
||||||
// The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
|
// The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
|
||||||
@ -45,9 +45,9 @@ pub mod v1 {
|
|||||||
pub locations: Vec<Location>,
|
pub locations: Vec<Location>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given protocol.
|
/// Creates a new `Request` with the given protocol.
|
||||||
pub fn new(protocol: &'a str) -> Self {
|
pub fn new(protocol: String) -> Self {
|
||||||
Self { protocol, fields: BTreeMap::new() }
|
Self { protocol, fields: BTreeMap::new() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ pub mod v1 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
thirdparty::Location,
|
thirdparty::Location,
|
||||||
RoomAliasId,
|
OwnedRoomAliasId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -25,10 +25,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `get_location_for_room_alias` endpoint.
|
/// Request type for the `get_location_for_room_alias` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The Matrix room alias to look up.
|
/// The Matrix room alias to look up.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub alias: &'a RoomAliasId,
|
pub alias: OwnedRoomAliasId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_location_for_room_alias` endpoint.
|
/// Response type for the `get_location_for_room_alias` endpoint.
|
||||||
@ -39,9 +39,9 @@ pub mod v1 {
|
|||||||
pub locations: Vec<Location>,
|
pub locations: Vec<Location>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room alias id.
|
/// Creates a new `Request` with the given room alias id.
|
||||||
pub fn new(alias: &'a RoomAliasId) -> Self {
|
pub fn new(alias: OwnedRoomAliasId) -> Self {
|
||||||
Self { alias }
|
Self { alias }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `get_protocol` endpoint.
|
/// Request type for the `get_protocol` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The name of the protocol.
|
/// The name of the protocol.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub protocol: &'a str,
|
pub protocol: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_protocol` endpoint.
|
/// Response type for the `get_protocol` endpoint.
|
||||||
@ -38,9 +38,9 @@ pub mod v1 {
|
|||||||
pub protocol: Protocol,
|
pub protocol: Protocol,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given protocol name.
|
/// Creates a new `Request` with the given protocol name.
|
||||||
pub fn new(protocol: &'a str) -> Self {
|
pub fn new(protocol: String) -> Self {
|
||||||
Self { protocol }
|
Self { protocol }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `get_user_for_protocol` endpoint.
|
/// Request type for the `get_user_for_protocol` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The protocol used to communicate to the third party network.
|
/// The protocol used to communicate to the third party network.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub protocol: &'a str,
|
pub protocol: String,
|
||||||
|
|
||||||
/// One or more custom fields that are passed to the AS to help identify the user.
|
/// One or more custom fields that are passed to the AS to help identify the user.
|
||||||
// The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
|
// The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
|
||||||
@ -46,9 +46,9 @@ pub mod v1 {
|
|||||||
pub users: Vec<User>,
|
pub users: Vec<User>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given protocol name.
|
/// Creates a new `Request` with the given protocol name.
|
||||||
pub fn new(protocol: &'a str) -> Self {
|
pub fn new(protocol: String) -> Self {
|
||||||
Self { protocol, fields: BTreeMap::new() }
|
Self { protocol, fields: BTreeMap::new() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ pub mod v1 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
thirdparty::User,
|
thirdparty::User,
|
||||||
UserId,
|
OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -25,10 +25,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `get_user_for_user_id` endpoint.
|
/// Request type for the `get_user_for_user_id` endpoint.
|
||||||
#[request]
|
#[request]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The Matrix User ID to look up.
|
/// The Matrix User ID to look up.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub userid: &'a UserId,
|
pub userid: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_user_for_user_id` endpoint.
|
/// Response type for the `get_user_for_user_id` endpoint.
|
||||||
@ -39,9 +39,9 @@ pub mod v1 {
|
|||||||
pub users: Vec<User>,
|
pub users: Vec<User>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user id.
|
/// Creates a new `Request` with the given user id.
|
||||||
pub fn new(userid: &'a UserId) -> Self {
|
pub fn new(userid: OwnedUserId) -> Self {
|
||||||
Self { userid }
|
Self { userid }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,26 +19,26 @@ pub mod request_registration_token_via_msisdn;
|
|||||||
pub mod unbind_3pid;
|
pub mod unbind_3pid;
|
||||||
pub mod whoami;
|
pub mod whoami;
|
||||||
|
|
||||||
use ruma_common::serde::{Incoming, StringEnum};
|
use ruma_common::serde::StringEnum;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::PrivOwnedStr;
|
use crate::PrivOwnedStr;
|
||||||
|
|
||||||
/// Additional authentication information for requestToken endpoints.
|
/// Additional authentication information for requestToken endpoints.
|
||||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct IdentityServerInfo<'a> {
|
pub struct IdentityServerInfo {
|
||||||
/// The ID server to send the onward request to as a hostname with an
|
/// 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.
|
/// appended colon and port number if the port is not the default.
|
||||||
pub id_server: &'a str,
|
pub id_server: String,
|
||||||
|
|
||||||
/// Access token previously registered with identity server.
|
/// Access token previously registered with identity server.
|
||||||
pub id_access_token: &'a str,
|
pub id_access_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IdentityServerInfo<'a> {
|
impl IdentityServerInfo {
|
||||||
/// Creates a new `IdentityServerInfo` with the given server name and access token.
|
/// Creates a new `IdentityServerInfo` with the given server name and access token.
|
||||||
pub fn new(id_server: &'a str, id_access_token: &'a str) -> Self {
|
pub fn new(id_server: String, id_access_token: String) -> Self {
|
||||||
Self { id_server, id_access_token }
|
Self { id_server, id_access_token }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, SessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
use crate::uiaa::{AuthData, UiaaResponse};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,16 +26,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `add_3pid` endpoint.
|
/// Request type for the `add_3pid` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Additional information for the User-Interactive Authentication API.
|
/// Additional information for the User-Interactive Authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
|
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: &'a SessionId,
|
pub sid: OwnedSessionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `add_3pid` endpoint.
|
/// Response type for the `add_3pid` endpoint.
|
||||||
@ -43,9 +43,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret and session identifier.
|
/// Creates a new `Request` with the given client secret and session identifier.
|
||||||
pub fn new(client_secret: &'a ClientSecret, sid: &'a SessionId) -> Self {
|
pub fn new(client_secret: OwnedClientSecret, sid: OwnedSessionId) -> Self {
|
||||||
Self { auth: None, client_secret, sid }
|
Self { auth: None, client_secret, sid }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, SessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
use crate::account::IdentityServerInfo;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,17 +26,17 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `bind_3pid` endpoint.
|
/// Request type for the `bind_3pid` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// The ID server to send the onward request to as a hostname with an
|
/// 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.
|
/// appended colon and port number if the port is not the default.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub identity_server_info: IdentityServerInfo<'a>,
|
pub identity_server_info: IdentityServerInfo,
|
||||||
|
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: &'a SessionId,
|
pub sid: OwnedSessionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `bind_3pid` endpoint.
|
/// Response type for the `bind_3pid` endpoint.
|
||||||
@ -44,13 +44,13 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret, identity server information and
|
/// Creates a new `Request` with the given client secret, identity server information and
|
||||||
/// session identifier.
|
/// session identifier.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
client_secret: &'a ClientSecret,
|
client_secret: OwnedClientSecret,
|
||||||
identity_server_info: IdentityServerInfo<'a>,
|
identity_server_info: IdentityServerInfo,
|
||||||
sid: &'a SessionId,
|
sid: OwnedSessionId,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { client_secret, identity_server_info, sid }
|
Self { client_secret, identity_server_info, sid }
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
use crate::uiaa::{AuthData, UiaaResponse};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,9 +26,9 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `change_password` endpoint.
|
/// Request type for the `change_password` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The new password for the account.
|
/// The new password for the account.
|
||||||
pub new_password: &'a str,
|
pub new_password: String,
|
||||||
|
|
||||||
/// True to revoke the user's other access tokens, and their associated devices if the
|
/// True to revoke the user's other access tokens, and their associated devices if the
|
||||||
/// request succeeds.
|
/// request succeeds.
|
||||||
@ -45,7 +45,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `change_password` endpoint.
|
/// Response type for the `change_password` endpoint.
|
||||||
@ -53,9 +53,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given password.
|
/// Creates a new `Request` with the given password.
|
||||||
pub fn new(new_password: &'a str) -> Self {
|
pub fn new(new_password: String) -> Self {
|
||||||
Self { new_password, logout_devices: true, auth: None }
|
Self { new_password, logout_devices: true, auth: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ pub mod v1 {
|
|||||||
|
|
||||||
/// Request type for the `check_registration_token_validity` endpoint.
|
/// Request type for the `check_registration_token_validity` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The registration token to check the validity of.
|
/// The registration token to check the validity of.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub registration_token: &'a str,
|
pub registration_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `check_registration_token_validity` endpoint.
|
/// Response type for the `check_registration_token_validity` endpoint.
|
||||||
@ -37,9 +37,9 @@ pub mod v1 {
|
|||||||
pub valid: bool,
|
pub valid: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given registration token.
|
/// Creates a new `Request` with the given registration token.
|
||||||
pub fn new(registration_token: &'a str) -> Self {
|
pub fn new(registration_token: String) -> Self {
|
||||||
Self { registration_token }
|
Self { registration_token }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
account::ThirdPartyIdRemovalStatus,
|
account::ThirdPartyIdRemovalStatus,
|
||||||
uiaa::{AuthData, IncomingAuthData, UiaaResponse},
|
uiaa::{AuthData, UiaaResponse},
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -30,15 +30,15 @@ pub mod v3 {
|
|||||||
/// Request type for the `deactivate` endpoint.
|
/// Request type for the `deactivate` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
|
|
||||||
/// Identity server from which to unbind the user's third party
|
/// Identity server from which to unbind the user's third party
|
||||||
/// identifier.
|
/// identifier.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub id_server: Option<&'a str>,
|
pub id_server: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `deactivate` endpoint.
|
/// Response type for the `deactivate` endpoint.
|
||||||
@ -48,7 +48,7 @@ pub mod v3 {
|
|||||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request {
|
||||||
/// Creates an empty `Request`.
|
/// Creates an empty `Request`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -27,16 +27,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_3pid` endpoint.
|
/// Request type for the `delete_3pid` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Identity server to delete from.
|
/// Identity server to delete from.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub id_server: Option<&'a str>,
|
pub id_server: Option<String>,
|
||||||
|
|
||||||
/// Medium of the 3PID to be removed.
|
/// Medium of the 3PID to be removed.
|
||||||
pub medium: Medium,
|
pub medium: Medium,
|
||||||
|
|
||||||
/// Third-party address being removed.
|
/// Third-party address being removed.
|
||||||
pub address: &'a str,
|
pub address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_3pid` endpoint.
|
/// Response type for the `delete_3pid` endpoint.
|
||||||
@ -46,9 +46,9 @@ pub mod v3 {
|
|||||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given medium and address.
|
/// Creates a new `Request` with the given medium and address.
|
||||||
pub fn new(medium: Medium, address: &'a str) -> Self {
|
pub fn new(medium: Medium, address: String) -> Self {
|
||||||
Self { id_server: None, medium, address }
|
Self { id_server: None, medium, address }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_username_availability` endpoint.
|
/// Request type for the `get_username_availability` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The username to check the availability of.
|
/// The username to check the availability of.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub username: &'a str,
|
pub username: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_username_availability` endpoint.
|
/// Response type for the `get_username_availability` endpoint.
|
||||||
@ -38,9 +38,9 @@ pub mod v3 {
|
|||||||
pub available: bool,
|
pub available: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given username.
|
/// Creates a new `Request` with the given username.
|
||||||
pub fn new(username: &'a str) -> Self {
|
pub fn new(username: String) -> Self {
|
||||||
Self { username }
|
Self { username }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, DeviceId, OwnedDeviceId, OwnedUserId,
|
metadata, OwnedDeviceId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{LoginType, RegistrationKind};
|
use super::{LoginType, RegistrationKind};
|
||||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
use crate::uiaa::{AuthData, UiaaResponse};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -32,32 +32,32 @@ pub mod v3 {
|
|||||||
/// Request type for the `register` endpoint.
|
/// Request type for the `register` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The desired password for the account.
|
/// The desired password for the account.
|
||||||
///
|
///
|
||||||
/// May be empty for accounts that should not be able to log in again
|
/// May be empty for accounts that should not be able to log in again
|
||||||
/// with a password, e.g., for guest or application service accounts.
|
/// with a password, e.g., for guest or application service accounts.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub password: Option<&'a str>,
|
pub password: Option<String>,
|
||||||
|
|
||||||
/// Localpart of the desired Matrix ID.
|
/// Localpart of the desired Matrix ID.
|
||||||
///
|
///
|
||||||
/// If omitted, the homeserver MUST generate a Matrix ID local part.
|
/// If omitted, the homeserver MUST generate a Matrix ID local part.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub username: Option<&'a str>,
|
pub username: Option<String>,
|
||||||
|
|
||||||
/// ID of the client device.
|
/// ID of the client device.
|
||||||
///
|
///
|
||||||
/// If this does not correspond to a known client device, a new device will be created.
|
/// If this does not correspond to a known client device, a new device will be created.
|
||||||
/// The server will auto-generate a device_id if this is not specified.
|
/// The server will auto-generate a device_id if this is not specified.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub device_id: Option<&'a DeviceId>,
|
pub device_id: Option<OwnedDeviceId>,
|
||||||
|
|
||||||
/// A display name to assign to the newly-created device.
|
/// A display name to assign to the newly-created device.
|
||||||
///
|
///
|
||||||
/// Ignored if `device_id` corresponds to a known device.
|
/// Ignored if `device_id` corresponds to a known device.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub initial_device_display_name: Option<&'a str>,
|
pub initial_device_display_name: Option<String>,
|
||||||
|
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
///
|
///
|
||||||
@ -66,7 +66,7 @@ pub mod v3 {
|
|||||||
/// It should be left empty, or omitted, unless an earlier call returned an response
|
/// It should be left empty, or omitted, unless an earlier call returned an response
|
||||||
/// with status code 401.
|
/// with status code 401.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
|
|
||||||
/// Kind of account to register
|
/// Kind of account to register
|
||||||
///
|
///
|
||||||
@ -87,7 +87,7 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// [admin]: https://spec.matrix.org/v1.4/application-service-api/#server-admin-style-permissions
|
/// [admin]: https://spec.matrix.org/v1.4/application-service-api/#server-admin-style-permissions
|
||||||
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
|
||||||
pub login_type: Option<&'a LoginType>,
|
pub login_type: Option<LoginType>,
|
||||||
|
|
||||||
/// If set to `true`, the client supports [refresh tokens].
|
/// If set to `true`, the client supports [refresh tokens].
|
||||||
///
|
///
|
||||||
@ -147,7 +147,7 @@ pub mod v3 {
|
|||||||
pub expires_in: Option<Duration>,
|
pub expires_in: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request {
|
||||||
/// Creates a new `Request` with all parameters defaulted.
|
/// Creates a new `Request` with all parameters defaulted.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, OwnedSessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
use crate::account::IdentityServerInfo;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -27,25 +27,25 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_3pid_management_token_via_email` endpoint.
|
/// Request type for the `request_3pid_management_token_via_email` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// The email address.
|
/// The email address.
|
||||||
pub email: &'a str,
|
pub email: String,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<&'a str>,
|
pub next_link: Option<String>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token.
|
/// Optional identity server hostname and access token.
|
||||||
///
|
///
|
||||||
/// Deprecated since r0.6.0.
|
/// Deprecated since r0.6.0.
|
||||||
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
pub identity_server_info: Option<IdentityServerInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_3pid_management_token_via_email` endpoint.
|
/// Response type for the `request_3pid_management_token_via_email` endpoint.
|
||||||
@ -68,9 +68,9 @@ pub mod v3 {
|
|||||||
pub submit_url: Option<String>,
|
pub submit_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the client secret, email and send-attempt counter.
|
/// Creates a new `Request` with the client secret, email and send-attempt counter.
|
||||||
pub fn new(client_secret: &'a ClientSecret, email: &'a str, send_attempt: UInt) -> Self {
|
pub fn new(client_secret: OwnedClientSecret, email: String, send_attempt: UInt) -> Self {
|
||||||
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, OwnedSessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
use crate::account::IdentityServerInfo;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -27,28 +27,28 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_3pid_management_token_via_msisdn` endpoint.
|
/// Request type for the `request_3pid_management_token_via_msisdn` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// Two-letter ISO 3166 country code for the phone number.
|
/// Two-letter ISO 3166 country code for the phone number.
|
||||||
pub country: &'a str,
|
pub country: String,
|
||||||
|
|
||||||
/// Phone number to validate.
|
/// Phone number to validate.
|
||||||
pub phone_number: &'a str,
|
pub phone_number: String,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<&'a str>,
|
pub next_link: Option<String>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token.
|
/// Optional identity server hostname and access token.
|
||||||
///
|
///
|
||||||
/// Deprecated since r0.6.0.
|
/// Deprecated since r0.6.0.
|
||||||
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
pub identity_server_info: Option<IdentityServerInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_3pid_management_token_via_msisdn` endpoint.
|
/// Response type for the `request_3pid_management_token_via_msisdn` endpoint.
|
||||||
@ -71,13 +71,13 @@ pub mod v3 {
|
|||||||
pub submit_url: Option<String>,
|
pub submit_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret, country code, phone number and
|
/// Creates a new `Request` with the given client secret, country code, phone number and
|
||||||
/// send-attempt counter.
|
/// send-attempt counter.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
client_secret: &'a ClientSecret,
|
client_secret: OwnedClientSecret,
|
||||||
country: &'a str,
|
country: String,
|
||||||
phone_number: &'a str,
|
phone_number: String,
|
||||||
send_attempt: UInt,
|
send_attempt: UInt,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
authentication::TokenType,
|
authentication::TokenType,
|
||||||
metadata, OwnedServerName, UserId,
|
metadata, OwnedServerName, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -27,10 +27,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_openid_token` endpoint.
|
/// Request type for the `request_openid_token` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// User ID of authenticated user.
|
/// User ID of authenticated user.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_openid_token` endpoint.
|
/// Response type for the `request_openid_token` endpoint.
|
||||||
@ -50,9 +50,9 @@ pub mod v3 {
|
|||||||
pub expires_in: Duration,
|
pub expires_in: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID.
|
/// Creates a new `Request` with the given user ID.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, OwnedSessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
use crate::account::IdentityServerInfo;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -27,25 +27,25 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_password_change_token_via_email` endpoint.
|
/// Request type for the `request_password_change_token_via_email` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// The email address.
|
/// The email address.
|
||||||
pub email: &'a str,
|
pub email: String,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<&'a str>,
|
pub next_link: Option<String>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token.
|
/// Optional identity server hostname and access token.
|
||||||
///
|
///
|
||||||
/// Deprecated since r0.6.0.
|
/// Deprecated since r0.6.0.
|
||||||
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
pub identity_server_info: Option<IdentityServerInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_password_change_token_via_email` endpoint.
|
/// Response type for the `request_password_change_token_via_email` endpoint.
|
||||||
@ -68,10 +68,10 @@ pub mod v3 {
|
|||||||
pub submit_url: Option<String>,
|
pub submit_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret, email address and send-attempt
|
/// Creates a new `Request` with the given client secret, email address and send-attempt
|
||||||
/// counter.
|
/// counter.
|
||||||
pub fn new(client_secret: &'a ClientSecret, email: &'a str, send_attempt: UInt) -> Self {
|
pub fn new(client_secret: OwnedClientSecret, email: String, send_attempt: UInt) -> Self {
|
||||||
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, OwnedSessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -25,22 +25,22 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_password_change_token_via_msisdn` endpoint.
|
/// Request type for the `request_password_change_token_via_msisdn` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// Two-letter ISO 3166 country code for the phone number.
|
/// Two-letter ISO 3166 country code for the phone number.
|
||||||
pub country: &'a str,
|
pub country: String,
|
||||||
|
|
||||||
/// Phone number to validate.
|
/// Phone number to validate.
|
||||||
pub phone_number: &'a str,
|
pub phone_number: String,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<&'a str>,
|
pub next_link: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_password_change_token_via_msisdn` endpoint.
|
/// Response type for the `request_password_change_token_via_msisdn` endpoint.
|
||||||
@ -63,13 +63,13 @@ pub mod v3 {
|
|||||||
pub submit_url: Option<String>,
|
pub submit_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret, country code, phone number and
|
/// Creates a new `Request` with the given client secret, country code, phone number and
|
||||||
/// send-attempt counter.
|
/// send-attempt counter.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
client_secret: &'a ClientSecret,
|
client_secret: OwnedClientSecret,
|
||||||
country: &'a str,
|
country: String,
|
||||||
phone_number: &'a str,
|
phone_number: String,
|
||||||
send_attempt: UInt,
|
send_attempt: UInt,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { client_secret, country, phone_number, send_attempt, next_link: None }
|
Self { client_secret, country, phone_number, send_attempt, next_link: None }
|
||||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, OwnedSessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
use crate::account::IdentityServerInfo;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -27,25 +27,25 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_registration_token_via_email` endpoint.
|
/// Request type for the `request_registration_token_via_email` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// The email address.
|
/// The email address.
|
||||||
pub email: &'a str,
|
pub email: String,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<&'a str>,
|
pub next_link: Option<String>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token.
|
/// Optional identity server hostname and access token.
|
||||||
///
|
///
|
||||||
/// Deprecated since r0.6.0.
|
/// Deprecated since r0.6.0.
|
||||||
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
pub identity_server_info: Option<IdentityServerInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_registration_token_via_email` endpoint.
|
/// Response type for the `request_registration_token_via_email` endpoint.
|
||||||
@ -68,10 +68,10 @@ pub mod v3 {
|
|||||||
pub submit_url: Option<String>,
|
pub submit_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret, email address and send-attempt
|
/// Creates a new `Request` with the given client secret, email address and send-attempt
|
||||||
/// counter.
|
/// counter.
|
||||||
pub fn new(client_secret: &'a ClientSecret, email: &'a str, send_attempt: UInt) -> Self {
|
pub fn new(client_secret: OwnedClientSecret, email: String, send_attempt: UInt) -> Self {
|
||||||
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, ClientSecret, OwnedSessionId,
|
metadata, OwnedClientSecret, OwnedSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
use crate::account::IdentityServerInfo;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -27,28 +27,28 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `request_registration_token_via_msisdn` endpoint.
|
/// Request type for the `request_registration_token_via_msisdn` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: &'a ClientSecret,
|
pub client_secret: OwnedClientSecret,
|
||||||
|
|
||||||
/// Two-letter ISO 3166 country code for the phone number.
|
/// Two-letter ISO 3166 country code for the phone number.
|
||||||
pub country: &'a str,
|
pub country: String,
|
||||||
|
|
||||||
/// Phone number to validate.
|
/// Phone number to validate.
|
||||||
pub phone_number: &'a str,
|
pub phone_number: String,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<&'a str>,
|
pub next_link: Option<String>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token.
|
/// Optional identity server hostname and access token.
|
||||||
///
|
///
|
||||||
/// Deprecated since r0.6.0.
|
/// Deprecated since r0.6.0.
|
||||||
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
pub identity_server_info: Option<IdentityServerInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `request_registration_token_via_msisdn` endpoint.
|
/// Response type for the `request_registration_token_via_msisdn` endpoint.
|
||||||
@ -71,13 +71,13 @@ pub mod v3 {
|
|||||||
pub submit_url: Option<String>,
|
pub submit_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given client secret, country code, phone number and
|
/// Creates a new `Request` with the given client secret, country code, phone number and
|
||||||
/// send-attempt counter.
|
/// send-attempt counter.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
client_secret: &'a ClientSecret,
|
client_secret: OwnedClientSecret,
|
||||||
country: &'a str,
|
country: String,
|
||||||
phone_number: &'a str,
|
phone_number: String,
|
||||||
send_attempt: UInt,
|
send_attempt: UInt,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -27,16 +27,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `unbind_3pid` endpoint.
|
/// Request type for the `unbind_3pid` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Identity server to unbind from.
|
/// Identity server to unbind from.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub id_server: Option<&'a str>,
|
pub id_server: Option<String>,
|
||||||
|
|
||||||
/// Medium of the 3PID to be removed.
|
/// Medium of the 3PID to be removed.
|
||||||
pub medium: Medium,
|
pub medium: Medium,
|
||||||
|
|
||||||
/// Third-party address being removed.
|
/// Third-party address being removed.
|
||||||
pub address: &'a str,
|
pub address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `unbind_3pid` endpoint.
|
/// Response type for the `unbind_3pid` endpoint.
|
||||||
@ -46,9 +46,9 @@ pub mod v3 {
|
|||||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given medium and third-party address.
|
/// Creates a new `Request` with the given medium and third-party address.
|
||||||
pub fn new(medium: Medium, address: &'a str) -> Self {
|
pub fn new(medium: Medium, address: String) -> Self {
|
||||||
Self { id_server: None, medium, address }
|
Self { id_server: None, medium, address }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomAliasId, RoomId,
|
metadata, OwnedRoomAliasId, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,13 +24,13 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `create_alias` endpoint.
|
/// Request type for the `create_alias` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room alias to set.
|
/// The room alias to set.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_alias: &'a RoomAliasId,
|
pub room_alias: OwnedRoomAliasId,
|
||||||
|
|
||||||
/// The room ID to set.
|
/// The room ID to set.
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `create_alias` endpoint.
|
/// Response type for the `create_alias` endpoint.
|
||||||
@ -38,9 +38,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room alias and room id.
|
/// Creates a new `Request` with the given room alias and room id.
|
||||||
pub fn new(room_alias: &'a RoomAliasId, room_id: &'a RoomId) -> Self {
|
pub fn new(room_alias: OwnedRoomAliasId, room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_alias, room_id }
|
Self { room_alias, room_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomAliasId,
|
metadata, OwnedRoomAliasId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_alias` endpoint.
|
/// Request type for the `delete_alias` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room alias to remove.
|
/// The room alias to remove.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_alias: &'a RoomAliasId,
|
pub room_alias: OwnedRoomAliasId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_alias` endpoint.
|
/// Response type for the `delete_alias` endpoint.
|
||||||
@ -35,9 +35,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room alias.
|
/// Creates a new `Request` with the given room alias.
|
||||||
pub fn new(room_alias: &'a RoomAliasId) -> Self {
|
pub fn new(room_alias: OwnedRoomAliasId) -> Self {
|
||||||
Self { room_alias }
|
Self { room_alias }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedRoomId, OwnedServerName, RoomAliasId,
|
metadata, OwnedRoomAliasId, OwnedRoomId, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_alias` endpoint.
|
/// Request type for the `get_alias` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room alias.
|
/// The room alias.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_alias: &'a RoomAliasId,
|
pub room_alias: OwnedRoomAliasId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_alias` endpoint.
|
/// Response type for the `get_alias` endpoint.
|
||||||
@ -40,9 +40,9 @@ pub mod v3 {
|
|||||||
pub servers: Vec<OwnedServerName>,
|
pub servers: Vec<OwnedServerName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room alias id.
|
/// Creates a new `Request` with the given room alias id.
|
||||||
pub fn new(room_alias: &'a RoomAliasId) -> Self {
|
pub fn new(room_alias: OwnedRoomAliasId) -> Self {
|
||||||
Self { room_alias }
|
Self { room_alias }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::room::Visibility;
|
use crate::room::Visibility;
|
||||||
@ -26,14 +26,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_room_visibility` endpoint.
|
/// Request type for the `set_room_visibility` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The protocol (network) ID to update the room list for.
|
/// The protocol (network) ID to update the room list for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub network_id: &'a str,
|
pub network_id: String,
|
||||||
|
|
||||||
/// The room ID to add to the directory.
|
/// The room ID to add to the directory.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// Whether the room should be visible (public) in the directory or not (private).
|
/// Whether the room should be visible (public) in the directory or not (private).
|
||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
@ -44,9 +44,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given network ID, room ID and visibility.
|
/// Creates a new `Request` with the given network ID, room ID and visibility.
|
||||||
pub fn new(network_id: &'a str, room_id: &'a RoomId, visibility: Visibility) -> Self {
|
pub fn new(network_id: String, room_id: OwnedRoomId, visibility: Visibility) -> Self {
|
||||||
Self { network_id, room_id, visibility }
|
Self { network_id, room_id, visibility }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `add_backup_keys` endpoint.
|
/// Request type for the `add_backup_keys` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to add keys to.
|
/// The backup version to add keys to.
|
||||||
///
|
///
|
||||||
/// Must be the current backup.
|
/// Must be the current backup.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// A map of room IDs to session IDs to key data to store.
|
/// A map of room IDs to session IDs to key data to store.
|
||||||
pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
|
pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
|
||||||
@ -53,9 +53,9 @@ pub mod v3 {
|
|||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version and room key backups.
|
/// Creates a new `Request` with the given version and room key backups.
|
||||||
pub fn new(version: &'a str, rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>) -> Self {
|
pub fn new(version: String, rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>) -> Self {
|
||||||
Self { version, rooms }
|
Self { version, rooms }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId,
|
OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::backup::KeyBackupData;
|
use crate::backup::KeyBackupData;
|
||||||
@ -32,16 +32,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `add_backup_keys_for_room` endpoint.
|
/// Request type for the `add_backup_keys_for_room` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to add keys to.
|
/// The backup version to add keys to.
|
||||||
///
|
///
|
||||||
/// Must be the current backup.
|
/// Must be the current backup.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The ID of the room to add keys to.
|
/// The ID of the room to add keys to.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// A map of session IDs to key data to store.
|
/// A map of session IDs to key data to store.
|
||||||
pub sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
pub sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
||||||
@ -60,11 +60,11 @@ pub mod v3 {
|
|||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version, room_id and sessions.
|
/// Creates a new `Request` with the given version, room_id and sessions.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
version: &'a str,
|
version: String,
|
||||||
room_id: &'a RoomId,
|
room_id: OwnedRoomId,
|
||||||
sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { version, room_id, sessions }
|
Self { version, room_id, sessions }
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId,
|
OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::backup::KeyBackupData;
|
use crate::backup::KeyBackupData;
|
||||||
@ -30,20 +30,20 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `add_backup_keys_for_session` endpoint.
|
/// Request type for the `add_backup_keys_for_session` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to add keys to.
|
/// The backup version to add keys to.
|
||||||
///
|
///
|
||||||
/// Must be the current backup.
|
/// Must be the current backup.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The ID of the room to add keys to.
|
/// The ID of the room to add keys to.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The ID of the megolm session to add keys to.
|
/// The ID of the megolm session to add keys to.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub session_id: &'a str,
|
pub session_id: String,
|
||||||
|
|
||||||
/// The key information to store.
|
/// The key information to store.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
@ -63,12 +63,12 @@ pub mod v3 {
|
|||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version, room_id, session_id and session_data.
|
/// Creates a new `Request` with the given version, room_id, session_id and session_data.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
version: &'a str,
|
version: String,
|
||||||
room_id: &'a RoomId,
|
room_id: OwnedRoomId,
|
||||||
session_id: &'a str,
|
session_id: String,
|
||||||
session_data: Raw<KeyBackupData>,
|
session_data: Raw<KeyBackupData>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { version, room_id, session_id, session_data }
|
Self { version, room_id, session_id, session_data }
|
||||||
|
@ -28,10 +28,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_backup_keys` endpoint.
|
/// Request type for the `delete_backup_keys` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version from which to delete keys.
|
/// The backup version from which to delete keys.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_backup_keys` endpoint.
|
/// Response type for the `delete_backup_keys` endpoint.
|
||||||
@ -47,9 +47,9 @@ pub mod v3 {
|
|||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version.
|
/// Creates a new `Request` with the given version.
|
||||||
pub fn new(version: &'a str) -> Self {
|
pub fn new(version: String) -> Self {
|
||||||
Self { version }
|
Self { version }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -26,14 +26,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_backup_keys_for_room` endpoint.
|
/// Request type for the `delete_backup_keys_for_room` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version from which to delete keys.
|
/// The backup version from which to delete keys.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The ID of the room to delete keys from.
|
/// The ID of the room to delete keys from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_backup_keys_for_room` endpoint.
|
/// Response type for the `delete_backup_keys_for_room` endpoint.
|
||||||
@ -49,10 +49,10 @@ pub mod v3 {
|
|||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version and room_id.
|
/// Creates a new `Request` with the given version and room_id.
|
||||||
|
|
||||||
pub fn new(version: &'a str, room_id: &'a RoomId) -> Self {
|
pub fn new(version: String, room_id: OwnedRoomId) -> Self {
|
||||||
Self { version, room_id }
|
Self { version, room_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -26,18 +26,18 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_backup_keys_for_session` endpoint.
|
/// Request type for the `delete_backup_keys_for_session` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version from which to delete keys.
|
/// The backup version from which to delete keys.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The ID of the room to delete keys from.
|
/// The ID of the room to delete keys from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The ID of the megolm session to delete keys from.
|
/// The ID of the megolm session to delete keys from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub session_id: &'a str,
|
pub session_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_backup_keys_for_session` endpoint.
|
/// Response type for the `delete_backup_keys_for_session` endpoint.
|
||||||
@ -53,9 +53,9 @@ pub mod v3 {
|
|||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version, room_id and session_id.
|
/// Creates a new `Request` with the given version, room_id and session_id.
|
||||||
pub fn new(version: &'a str, room_id: &'a RoomId, session_id: &'a str) -> Self {
|
pub fn new(version: String, room_id: OwnedRoomId, session_id: String) -> Self {
|
||||||
Self { version, room_id, session_id }
|
Self { version, room_id, session_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_backup_version` endpoint.
|
/// Request type for the `delete_backup_version` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to delete.
|
/// The backup version to delete.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_backup_version` endpoint.
|
/// Response type for the `delete_backup_version` endpoint.
|
||||||
@ -38,9 +38,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version, room_id and sessions.
|
/// Creates a new `Request` with the given version, room_id and sessions.
|
||||||
pub fn new(version: &'a str) -> Self {
|
pub fn new(version: String) -> Self {
|
||||||
Self { version }
|
Self { version }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_backup_info` endpoint.
|
/// Request type for the `get_backup_info` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to retrieve info from.
|
/// The backup version to retrieve info from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_backup_info` endpoint.
|
/// Response type for the `get_backup_info` endpoint.
|
||||||
@ -56,9 +56,9 @@ pub mod v3 {
|
|||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version.
|
/// Creates a new `Request` with the given version.
|
||||||
pub fn new(version: &'a str) -> Self {
|
pub fn new(version: String) -> Self {
|
||||||
Self { version }
|
Self { version }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_backup_keys` endpoint.
|
/// Request type for the `get_backup_keys` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to retrieve keys from.
|
/// The backup version to retrieve keys from.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_backup_keys` endpoint.
|
/// Response type for the `get_backup_keys` endpoint.
|
||||||
@ -42,9 +42,9 @@ pub mod v3 {
|
|||||||
pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
|
pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version.
|
/// Creates a new `Request` with the given version.
|
||||||
pub fn new(version: &'a str) -> Self {
|
pub fn new(version: String) -> Self {
|
||||||
Self { version }
|
Self { version }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId,
|
OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::backup::KeyBackupData;
|
use crate::backup::KeyBackupData;
|
||||||
@ -31,14 +31,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_backup_keys_for_room` endpoint.
|
/// Request type for the `get_backup_keys_for_room` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to retrieve keys from.
|
/// The backup version to retrieve keys from.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The ID of the room that the requested key is for.
|
/// The ID of the room that the requested key is for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_backup_keys_for_room` endpoint.
|
/// Response type for the `get_backup_keys_for_room` endpoint.
|
||||||
@ -48,9 +48,9 @@ pub mod v3 {
|
|||||||
pub sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
pub sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version and room_id.
|
/// Creates a new `Request` with the given version and room_id.
|
||||||
pub fn new(version: &'a str, room_id: &'a RoomId) -> Self {
|
pub fn new(version: String, room_id: OwnedRoomId) -> Self {
|
||||||
Self { version, room_id }
|
Self { version, room_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId,
|
OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::backup::KeyBackupData;
|
use crate::backup::KeyBackupData;
|
||||||
@ -29,18 +29,18 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_backup_keys_for_session` endpoint.
|
/// Request type for the `get_backup_keys_for_session` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version to retrieve keys from.
|
/// The backup version to retrieve keys from.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The ID of the room that the requested key is for.
|
/// The ID of the room that the requested key is for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The ID of the megolm session whose key is requested.
|
/// The ID of the megolm session whose key is requested.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub session_id: &'a str,
|
pub session_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_backup_keys_for_session` endpoint.
|
/// Response type for the `get_backup_keys_for_session` endpoint.
|
||||||
@ -51,9 +51,9 @@ pub mod v3 {
|
|||||||
pub key_data: Raw<KeyBackupData>,
|
pub key_data: Raw<KeyBackupData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given version, room_id and session_id.
|
/// Creates a new `Request` with the given version, room_id and session_id.
|
||||||
pub fn new(version: &'a str, room_id: &'a RoomId, session_id: &'a str) -> Self {
|
pub fn new(version: String, room_id: OwnedRoomId, session_id: String) -> Self {
|
||||||
Self { version, room_id, session_id }
|
Self { version, room_id, session_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `update_backup_version` endpoint.
|
/// Request type for the `update_backup_version` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The backup version.
|
/// The backup version.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub version: &'a str,
|
pub version: String,
|
||||||
|
|
||||||
/// The algorithm used for storing backups.
|
/// The algorithm used for storing backups.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
@ -42,9 +42,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given backup version and algorithm.
|
/// Creates a new `Request` with the given backup version and algorithm.
|
||||||
pub fn new(version: &'a str, algorithm: Raw<BackupAlgorithm>) -> Self {
|
pub fn new(version: String, algorithm: Raw<BackupAlgorithm>) -> Self {
|
||||||
Self { version, algorithm }
|
Self { version, algorithm }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
events::AnyGlobalAccountDataEventContent,
|
events::AnyGlobalAccountDataEventContent,
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
UserId,
|
OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -27,14 +27,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_global_account_data` endpoint.
|
/// Request type for the `get_global_account_data` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// User ID of user for whom to retrieve data.
|
/// User ID of user for whom to retrieve data.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// Type of data to retrieve.
|
/// Type of data to retrieve.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_type: &'a str,
|
pub event_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_global_account_data` endpoint.
|
/// Response type for the `get_global_account_data` endpoint.
|
||||||
@ -47,9 +47,9 @@ pub mod v3 {
|
|||||||
pub account_data: Raw<AnyGlobalAccountDataEventContent>,
|
pub account_data: Raw<AnyGlobalAccountDataEventContent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID and event type.
|
/// Creates a new `Request` with the given user ID and event type.
|
||||||
pub fn new(user_id: &'a UserId, event_type: &'a str) -> Self {
|
pub fn new(user_id: OwnedUserId, event_type: String) -> Self {
|
||||||
Self { user_id, event_type }
|
Self { user_id, event_type }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
events::AnyRoomAccountDataEventContent,
|
events::AnyRoomAccountDataEventContent,
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId, UserId,
|
OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -27,18 +27,18 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_room_account_data` endpoint.
|
/// Request type for the `get_room_account_data` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// User ID of user for whom to retrieve data.
|
/// User ID of user for whom to retrieve data.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// Room ID for which to retrieve data.
|
/// Room ID for which to retrieve data.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// Type of data to retrieve.
|
/// Type of data to retrieve.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_type: &'a str,
|
pub event_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_room_account_data` endpoint.
|
/// Response type for the `get_room_account_data` endpoint.
|
||||||
@ -51,9 +51,9 @@ pub mod v3 {
|
|||||||
pub account_data: Raw<AnyRoomAccountDataEventContent>,
|
pub account_data: Raw<AnyRoomAccountDataEventContent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID, room ID and event type.
|
/// Creates a new `Request` with the given user ID, room ID and event type.
|
||||||
pub fn new(user_id: &'a UserId, room_id: &'a RoomId, event_type: &'a str) -> Self {
|
pub fn new(user_id: OwnedUserId, room_id: OwnedRoomId, event_type: String) -> Self {
|
||||||
Self { user_id, room_id, event_type }
|
Self { user_id, room_id, event_type }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ pub mod v3 {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
UserId,
|
OwnedUserId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_global_account_data` endpoint.
|
/// Request type for the `set_global_account_data` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The ID of the user to set account_data for.
|
/// The ID of the user to set account_data for.
|
||||||
///
|
///
|
||||||
/// The access token must be authorized to make requests for this user ID.
|
/// The access token must be authorized to make requests for this user ID.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The event type of the account_data to set.
|
/// The event type of the account_data to set.
|
||||||
///
|
///
|
||||||
@ -56,14 +56,14 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given data, event type and user ID.
|
/// Creates a new `Request` with the given data, event type and user ID.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||||
pub fn new<T>(user_id: &'a UserId, data: &'a T) -> serde_json::Result<Self>
|
pub fn new<T>(user_id: OwnedUserId, data: &T) -> serde_json::Result<Self>
|
||||||
where
|
where
|
||||||
T: GlobalAccountDataEventContent,
|
T: GlobalAccountDataEventContent,
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Creates a new `Request` with the given raw data, event type and user ID.
|
/// Creates a new `Request` with the given raw data, event type and user ID.
|
||||||
pub fn new_raw(
|
pub fn new_raw(
|
||||||
user_id: &'a UserId,
|
user_id: OwnedUserId,
|
||||||
event_type: GlobalAccountDataEventType,
|
event_type: GlobalAccountDataEventType,
|
||||||
data: Raw<AnyGlobalAccountDataEventContent>,
|
data: Raw<AnyGlobalAccountDataEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId, UserId,
|
OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||||
|
|
||||||
@ -30,16 +30,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_room_account_data` endpoint.
|
/// Request type for the `set_room_account_data` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The ID of the user to set account_data for.
|
/// The ID of the user to set account_data for.
|
||||||
///
|
///
|
||||||
/// The access token must be authorized to make requests for this user ID.
|
/// The access token must be authorized to make requests for this user ID.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// 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)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The event type of the account_data to set.
|
/// The event type of the account_data to set.
|
||||||
///
|
///
|
||||||
@ -59,7 +59,7 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given data, event type, room ID and user ID.
|
/// Creates a new `Request` with the given data, event type, room ID and user ID.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
@ -67,9 +67,9 @@ pub mod v3 {
|
|||||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||||
pub fn new<T>(
|
pub fn new<T>(
|
||||||
user_id: &'a UserId,
|
user_id: OwnedUserId,
|
||||||
room_id: &'a RoomId,
|
room_id: OwnedRoomId,
|
||||||
data: &'a T,
|
data: &T,
|
||||||
) -> serde_json::Result<Self>
|
) -> serde_json::Result<Self>
|
||||||
where
|
where
|
||||||
T: RoomAccountDataEventContent,
|
T: RoomAccountDataEventContent,
|
||||||
@ -84,8 +84,8 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Creates a new `Request` with the given raw data, event type, room ID and user ID.
|
/// Creates a new `Request` with the given raw data, event type, room ID and user ID.
|
||||||
pub fn new_raw(
|
pub fn new_raw(
|
||||||
user_id: &'a UserId,
|
user_id: OwnedUserId,
|
||||||
room_id: &'a RoomId,
|
room_id: OwnedRoomId,
|
||||||
event_type: RoomAccountDataEventType,
|
event_type: RoomAccountDataEventType,
|
||||||
data: Raw<AnyRoomAccountDataEventContent>,
|
data: Raw<AnyRoomAccountDataEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -13,10 +13,10 @@ pub mod v3 {
|
|||||||
events::{AnyStateEvent, AnyTimelineEvent},
|
events::{AnyStateEvent, AnyTimelineEvent},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
EventId, RoomId,
|
OwnedEventId, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::filter::{IncomingRoomEventFilter, RoomEventFilter};
|
use crate::filter::RoomEventFilter;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
@ -30,14 +30,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_context` endpoint.
|
/// Request type for the `get_context` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to get events from.
|
/// The room to get events from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The event to get context around.
|
/// The event to get context around.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: &'a EventId,
|
pub event_id: OwnedEventId,
|
||||||
|
|
||||||
/// The maximum number of events to return.
|
/// The maximum number of events to return.
|
||||||
///
|
///
|
||||||
@ -53,7 +53,7 @@ pub mod v3 {
|
|||||||
default,
|
default,
|
||||||
skip_serializing_if = "RoomEventFilter::is_empty"
|
skip_serializing_if = "RoomEventFilter::is_empty"
|
||||||
)]
|
)]
|
||||||
pub filter: RoomEventFilter<'a>,
|
pub filter: RoomEventFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_context` endpoint.
|
/// Response type for the `get_context` endpoint.
|
||||||
@ -87,9 +87,9 @@ pub mod v3 {
|
|||||||
pub state: Vec<Raw<AnyStateEvent>>,
|
pub state: Vec<Raw<AnyStateEvent>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id and event id.
|
/// Creates a new `Request` with the given room id and event id.
|
||||||
pub fn new(room_id: &'a RoomId, event_id: &'a EventId) -> Self {
|
pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
|
||||||
Self { room_id, event_id, limit: default_limit(), filter: RoomEventFilter::default() }
|
Self { room_id, event_id, limit: default_limit(), filter: RoomEventFilter::default() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, DeviceId,
|
metadata, OwnedDeviceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
use crate::uiaa::{AuthData, UiaaResponse};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: DELETE,
|
method: DELETE,
|
||||||
@ -26,14 +26,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_device` endpoint.
|
/// Request type for the `delete_device` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The device to delete.
|
/// The device to delete.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub device_id: &'a DeviceId,
|
pub device_id: OwnedDeviceId,
|
||||||
|
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_device` endpoint.
|
/// Response type for the `delete_device` endpoint.
|
||||||
@ -41,9 +41,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given device ID.
|
/// Creates a new `Request` with the given device ID.
|
||||||
pub fn new(device_id: &'a DeviceId) -> Self {
|
pub fn new(device_id: OwnedDeviceId) -> Self {
|
||||||
Self { device_id, auth: None }
|
Self { device_id, auth: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
metadata, OwnedDeviceId,
|
metadata, OwnedDeviceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
use crate::uiaa::{AuthData, UiaaResponse};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,13 +26,13 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_devices` endpoint.
|
/// Request type for the `delete_devices` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// List of devices to delete.
|
/// List of devices to delete.
|
||||||
pub devices: &'a [OwnedDeviceId],
|
pub devices: Vec<OwnedDeviceId>,
|
||||||
|
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_devices` endpoint.
|
/// Response type for the `delete_devices` endpoint.
|
||||||
@ -40,9 +40,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given device list.
|
/// Creates a new `Request` with the given device list.
|
||||||
pub fn new(devices: &'a [OwnedDeviceId]) -> Self {
|
pub fn new(devices: Vec<OwnedDeviceId>) -> Self {
|
||||||
Self { devices, auth: None }
|
Self { devices, auth: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, DeviceId,
|
metadata, OwnedDeviceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::device::Device;
|
use crate::device::Device;
|
||||||
@ -26,10 +26,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_device` endpoint.
|
/// Request type for the `get_device` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The device to retrieve.
|
/// The device to retrieve.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub device_id: &'a DeviceId,
|
pub device_id: OwnedDeviceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_device` endpoint.
|
/// Response type for the `get_device` endpoint.
|
||||||
@ -40,9 +40,9 @@ pub mod v3 {
|
|||||||
pub device: Device,
|
pub device: Device,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given device ID.
|
/// Creates a new `Request` with the given device ID.
|
||||||
pub fn new(device_id: &'a DeviceId) -> Self {
|
pub fn new(device_id: OwnedDeviceId) -> Self {
|
||||||
Self { device_id }
|
Self { device_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, DeviceId,
|
metadata, OwnedDeviceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,16 +24,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `update_device` endpoint.
|
/// Request type for the `update_device` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The device to update.
|
/// The device to update.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub device_id: &'a DeviceId,
|
pub device_id: OwnedDeviceId,
|
||||||
|
|
||||||
/// The new display name for this device.
|
/// The new display name for this device.
|
||||||
///
|
///
|
||||||
/// If this is `None`, the display name won't be changed.
|
/// If this is `None`, the display name won't be changed.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub display_name: Option<&'a str>,
|
pub display_name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `update_device` endpoint.
|
/// Response type for the `update_device` endpoint.
|
||||||
@ -41,9 +41,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given device ID.
|
/// Creates a new `Request` with the given device ID.
|
||||||
pub fn new(device_id: &'a DeviceId) -> Self {
|
pub fn new(device_id: OwnedDeviceId) -> Self {
|
||||||
Self { device_id, display_name: None }
|
Self { device_id, display_name: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
|||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
directory::PublicRoomsChunk,
|
directory::PublicRoomsChunk,
|
||||||
metadata, ServerName,
|
metadata, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -27,7 +27,7 @@ pub mod v3 {
|
|||||||
/// Request type for the `get_public_rooms` endpoint.
|
/// Request type for the `get_public_rooms` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Limit for the number of results to return.
|
/// Limit for the number of results to return.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
@ -36,14 +36,14 @@ pub mod v3 {
|
|||||||
/// Pagination token from a previous request.
|
/// Pagination token from a previous request.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub since: Option<&'a str>,
|
pub since: Option<String>,
|
||||||
|
|
||||||
/// The server to fetch the public room lists from.
|
/// The server to fetch the public room lists from.
|
||||||
///
|
///
|
||||||
/// `None` means the server this request is sent to.
|
/// `None` means the server this request is sent to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub server: Option<&'a ServerName>,
|
pub server: Option<OwnedServerName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_public_rooms` endpoint.
|
/// Response type for the `get_public_rooms` endpoint.
|
||||||
@ -65,7 +65,7 @@ pub mod v3 {
|
|||||||
pub total_room_count_estimate: Option<UInt>,
|
pub total_room_count_estimate: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates an empty `Request`.
|
/// Creates an empty `Request`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
@ -93,8 +93,8 @@ pub mod v3 {
|
|||||||
|
|
||||||
let req = super::Request {
|
let req = super::Request {
|
||||||
limit: Some(uint!(10)),
|
limit: Some(uint!(10)),
|
||||||
since: Some("hello"),
|
since: Some("hello".to_owned()),
|
||||||
server: Some(server_name!("test.tld")),
|
server: Some(server_name!("test.tld").to_owned()),
|
||||||
}
|
}
|
||||||
.try_into_http_request::<Vec<u8>>(
|
.try_into_http_request::<Vec<u8>>(
|
||||||
"https://homeserver.tld",
|
"https://homeserver.tld",
|
||||||
|
@ -10,8 +10,8 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
directory::{Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork},
|
directory::{Filter, PublicRoomsChunk, RoomNetwork},
|
||||||
metadata, ServerName,
|
metadata, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -27,13 +27,13 @@ pub mod v3 {
|
|||||||
/// Request type for the `get_public_rooms_filtered` endpoint.
|
/// Request type for the `get_public_rooms_filtered` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The server to fetch the public room lists from.
|
/// The server to fetch the public room lists from.
|
||||||
///
|
///
|
||||||
/// `None` means the server this request is sent to.
|
/// `None` means the server this request is sent to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub server: Option<&'a ServerName>,
|
pub server: Option<OwnedServerName>,
|
||||||
|
|
||||||
/// Limit for the number of results to return.
|
/// Limit for the number of results to return.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -41,15 +41,15 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Pagination token from a previous request.
|
/// Pagination token from a previous request.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub since: Option<&'a str>,
|
pub since: Option<String>,
|
||||||
|
|
||||||
/// Filter to apply to the results.
|
/// Filter to apply to the results.
|
||||||
#[serde(default, skip_serializing_if = "Filter::is_empty")]
|
#[serde(default, skip_serializing_if = "Filter::is_empty")]
|
||||||
pub filter: Filter<'a>,
|
pub filter: Filter,
|
||||||
|
|
||||||
/// Network to fetch the public room lists from.
|
/// Network to fetch the public room lists from.
|
||||||
#[serde(flatten, skip_serializing_if = "ruma_common::serde::is_default")]
|
#[serde(flatten, skip_serializing_if = "ruma_common::serde::is_default")]
|
||||||
pub room_network: RoomNetwork<'a>,
|
pub room_network: RoomNetwork,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_public_rooms_filtered` endpoint.
|
/// Response type for the `get_public_rooms_filtered` endpoint.
|
||||||
@ -72,7 +72,7 @@ pub mod v3 {
|
|||||||
pub total_room_count_estimate: Option<UInt>,
|
pub total_room_count_estimate: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request {
|
||||||
/// Creates an empty `Request`.
|
/// Creates an empty `Request`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::room::Visibility;
|
use crate::room::Visibility;
|
||||||
@ -26,10 +26,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_room_visibility` endpoint.
|
/// Request type for the `get_room_visibility` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The ID of the room of which to request the visibility.
|
/// The ID of the room of which to request the visibility.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_room_visibility` endpoint.
|
/// Response type for the `get_room_visibility` endpoint.
|
||||||
@ -39,9 +39,9 @@ pub mod v3 {
|
|||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID.
|
/// Creates a new `Request` with the given room ID.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id }
|
Self { room_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::room::Visibility;
|
use crate::room::Visibility;
|
||||||
@ -26,10 +26,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_room_visibility` endpoint.
|
/// Request type for the `set_room_visibility` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The ID of the room of which to set the visibility.
|
/// The ID of the room of which to set the visibility.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// New visibility setting for the room.
|
/// New visibility setting for the room.
|
||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
@ -40,9 +40,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID and visibility.
|
/// Creates a new `Request` with the given room ID and visibility.
|
||||||
pub fn new(room_id: &'a RoomId, visibility: Visibility) -> Self {
|
pub fn new(room_id: OwnedRoomId, visibility: Visibility) -> Self {
|
||||||
Self { room_id, visibility }
|
Self { room_id, visibility }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,8 @@ mod lazy_load;
|
|||||||
mod url;
|
mod url;
|
||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{serde::StringEnum, OwnedRoomId, OwnedUserId};
|
||||||
serde::{Incoming, StringEnum},
|
use serde::{Deserialize, Serialize};
|
||||||
OwnedRoomId, OwnedUserId,
|
|
||||||
};
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use crate::PrivOwnedStr;
|
use crate::PrivOwnedStr;
|
||||||
|
|
||||||
@ -35,24 +32,23 @@ pub enum EventFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Filters to be applied to room events.
|
/// Filters to be applied to room events.
|
||||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(Clone, Default, Serialize)]
|
pub struct RoomEventFilter {
|
||||||
pub struct RoomEventFilter<'a> {
|
|
||||||
/// A list of event types to exclude.
|
/// A list of event types to exclude.
|
||||||
///
|
///
|
||||||
/// If this list is absent then no event types are excluded. A matching type will be excluded
|
/// If this list is absent then no event types are excluded. A matching type will be excluded
|
||||||
/// even if it is listed in the 'types' filter. A '*' can be used as a wildcard to match any
|
/// even if it is listed in the 'types' filter. A '*' can be used as a wildcard to match any
|
||||||
/// sequence of characters.
|
/// sequence of characters.
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub not_types: &'a [String],
|
pub not_types: Vec<String>,
|
||||||
|
|
||||||
/// A list of room IDs to exclude.
|
/// A list of room IDs to exclude.
|
||||||
///
|
///
|
||||||
/// If this list is absent then no rooms are excluded. A matching room will be excluded even if
|
/// If this list is absent then no rooms are excluded. A matching room will be excluded even if
|
||||||
/// it is listed in the 'rooms' filter.
|
/// it is listed in the 'rooms' filter.
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub not_rooms: &'a [OwnedRoomId],
|
pub not_rooms: Vec<OwnedRoomId>,
|
||||||
|
|
||||||
/// The maximum number of events to return.
|
/// The maximum number of events to return.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -62,27 +58,27 @@ pub struct RoomEventFilter<'a> {
|
|||||||
///
|
///
|
||||||
/// If this list is absent then all rooms are included.
|
/// If this list is absent then all rooms are included.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub rooms: Option<&'a [OwnedRoomId]>,
|
pub rooms: Option<Vec<OwnedRoomId>>,
|
||||||
|
|
||||||
/// A list of sender IDs to exclude.
|
/// A list of sender IDs to exclude.
|
||||||
///
|
///
|
||||||
/// If this list is absent then no senders are excluded. A matching sender will be excluded
|
/// If this list is absent then no senders are excluded. A matching sender will be excluded
|
||||||
/// even if it is listed in the 'senders' filter.
|
/// even if it is listed in the 'senders' filter.
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub not_senders: &'a [OwnedUserId],
|
pub not_senders: Vec<OwnedUserId>,
|
||||||
|
|
||||||
/// A list of senders IDs to include.
|
/// A list of senders IDs to include.
|
||||||
///
|
///
|
||||||
/// If this list is absent then all senders are included.
|
/// If this list is absent then all senders are included.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub senders: Option<&'a [OwnedUserId]>,
|
pub senders: Option<Vec<OwnedUserId>>,
|
||||||
|
|
||||||
/// A list of event types to include.
|
/// A list of event types to include.
|
||||||
///
|
///
|
||||||
/// If this list is absent then all event types are included. A '*' can be used as a wildcard
|
/// If this list is absent then all event types are included. A '*' can be used as a wildcard
|
||||||
/// to match any sequence of characters.
|
/// to match any sequence of characters.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub types: Option<&'a [String]>,
|
pub types: Option<Vec<String>>,
|
||||||
|
|
||||||
/// Controls whether to include events with a URL key in their content.
|
/// Controls whether to include events with a URL key in their content.
|
||||||
///
|
///
|
||||||
@ -108,7 +104,7 @@ pub struct RoomEventFilter<'a> {
|
|||||||
pub unread_thread_notifications: bool,
|
pub unread_thread_notifications: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RoomEventFilter<'a> {
|
impl RoomEventFilter {
|
||||||
/// Creates an empty `RoomEventFilter`.
|
/// Creates an empty `RoomEventFilter`.
|
||||||
///
|
///
|
||||||
/// You can also use the [`Default`] implementation.
|
/// You can also use the [`Default`] implementation.
|
||||||
@ -118,7 +114,7 @@ impl<'a> RoomEventFilter<'a> {
|
|||||||
|
|
||||||
/// Creates a new `RoomEventFilter` that can be used to ignore all room events.
|
/// Creates a new `RoomEventFilter` that can be used to ignore all room events.
|
||||||
pub fn ignore_all() -> Self {
|
pub fn ignore_all() -> Self {
|
||||||
Self { types: Some(&[]), ..Default::default() }
|
Self { types: Some(vec![]), ..Default::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if all fields are empty.
|
/// Returns `true` if all fields are empty.
|
||||||
@ -136,27 +132,10 @@ impl<'a> RoomEventFilter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncomingRoomEventFilter {
|
|
||||||
/// Returns `true` if all fields are empty.
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.not_types.is_empty()
|
|
||||||
&& self.not_rooms.is_empty()
|
|
||||||
&& self.limit.is_none()
|
|
||||||
&& self.rooms.is_none()
|
|
||||||
&& self.not_senders.is_empty()
|
|
||||||
&& self.senders.is_none()
|
|
||||||
&& self.types.is_none()
|
|
||||||
&& self.url_filter.is_none()
|
|
||||||
&& self.lazy_load_options.is_disabled()
|
|
||||||
&& !self.unread_thread_notifications
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Filters to be applied to room data.
|
/// Filters to be applied to room data.
|
||||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(Clone, Default, Serialize)]
|
pub struct RoomFilter {
|
||||||
pub struct RoomFilter<'a> {
|
|
||||||
/// Include rooms that the user has left in the sync.
|
/// Include rooms that the user has left in the sync.
|
||||||
///
|
///
|
||||||
/// Defaults to `false`.
|
/// Defaults to `false`.
|
||||||
@ -165,20 +144,20 @@ pub struct RoomFilter<'a> {
|
|||||||
|
|
||||||
/// The per user account data to include for rooms.
|
/// The per user account data to include for rooms.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub account_data: RoomEventFilter<'a>,
|
pub account_data: RoomEventFilter,
|
||||||
|
|
||||||
/// The message and state update events to include for rooms.
|
/// The message and state update events to include for rooms.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub timeline: RoomEventFilter<'a>,
|
pub timeline: RoomEventFilter,
|
||||||
|
|
||||||
/// The events that aren't recorded in the room history, e.g. typing and receipts, to include
|
/// The events that aren't recorded in the room history, e.g. typing and receipts, to include
|
||||||
/// for rooms.
|
/// for rooms.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub ephemeral: RoomEventFilter<'a>,
|
pub ephemeral: RoomEventFilter,
|
||||||
|
|
||||||
/// The state events to include for rooms.
|
/// The state events to include for rooms.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub state: RoomEventFilter<'a>,
|
pub state: RoomEventFilter,
|
||||||
|
|
||||||
/// A list of room IDs to exclude.
|
/// A list of room IDs to exclude.
|
||||||
///
|
///
|
||||||
@ -186,17 +165,17 @@ pub struct RoomFilter<'a> {
|
|||||||
/// it is listed in the 'rooms' filter. This filter is applied before the filters in
|
/// it is listed in the 'rooms' filter. This filter is applied before the filters in
|
||||||
/// `ephemeral`, `state`, `timeline` or `account_data`.
|
/// `ephemeral`, `state`, `timeline` or `account_data`.
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub not_rooms: &'a [OwnedRoomId],
|
pub not_rooms: Vec<OwnedRoomId>,
|
||||||
|
|
||||||
/// A list of room IDs to include.
|
/// A list of room IDs to include.
|
||||||
///
|
///
|
||||||
/// If this list is absent then all rooms are included. This filter is applied before the
|
/// If this list is absent then all rooms are included. This filter is applied before the
|
||||||
/// filters in `ephemeral`, `state`, `timeline` or `account_data`.
|
/// filters in `ephemeral`, `state`, `timeline` or `account_data`.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub rooms: Option<&'a [OwnedRoomId]>,
|
pub rooms: Option<Vec<OwnedRoomId>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RoomFilter<'a> {
|
impl RoomFilter {
|
||||||
/// Creates an empty `RoomFilter`.
|
/// Creates an empty `RoomFilter`.
|
||||||
///
|
///
|
||||||
/// You can also use the [`Default`] implementation.
|
/// You can also use the [`Default`] implementation.
|
||||||
@ -206,7 +185,7 @@ impl<'a> RoomFilter<'a> {
|
|||||||
|
|
||||||
/// Creates a new `RoomFilter` that can be used to ignore all room events (of any type).
|
/// Creates a new `RoomFilter` that can be used to ignore all room events (of any type).
|
||||||
pub fn ignore_all() -> Self {
|
pub fn ignore_all() -> Self {
|
||||||
Self { rooms: Some(&[]), ..Default::default() }
|
Self { rooms: Some(vec![]), ..Default::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if all fields are empty.
|
/// Returns `true` if all fields are empty.
|
||||||
@ -221,31 +200,17 @@ impl<'a> RoomFilter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncomingRoomFilter {
|
|
||||||
/// Returns `true` if all fields are empty.
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
!self.include_leave
|
|
||||||
&& self.account_data.is_empty()
|
|
||||||
&& self.timeline.is_empty()
|
|
||||||
&& self.ephemeral.is_empty()
|
|
||||||
&& self.state.is_empty()
|
|
||||||
&& self.not_rooms.is_empty()
|
|
||||||
&& self.rooms.is_none()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Filter for non-room data.
|
/// Filter for non-room data.
|
||||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(Clone, Default, Serialize)]
|
pub struct Filter {
|
||||||
pub struct Filter<'a> {
|
|
||||||
/// A list of event types to exclude.
|
/// A list of event types to exclude.
|
||||||
///
|
///
|
||||||
/// If this list is absent then no event types are excluded. A matching type will be excluded
|
/// If this list is absent then no event types are excluded. A matching type will be excluded
|
||||||
/// even if it is listed in the 'types' filter. A '*' can be used as a wildcard to match any
|
/// even if it is listed in the 'types' filter. A '*' can be used as a wildcard to match any
|
||||||
/// sequence of characters.
|
/// sequence of characters.
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub not_types: &'a [String],
|
pub not_types: Vec<String>,
|
||||||
|
|
||||||
/// The maximum number of events to return.
|
/// The maximum number of events to return.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -255,24 +220,24 @@ pub struct Filter<'a> {
|
|||||||
///
|
///
|
||||||
/// If this list is absent then all senders are included.
|
/// If this list is absent then all senders are included.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub senders: Option<&'a [OwnedUserId]>,
|
pub senders: Option<Vec<OwnedUserId>>,
|
||||||
|
|
||||||
/// A list of event types to include.
|
/// A list of event types to include.
|
||||||
///
|
///
|
||||||
/// If this list is absent then all event types are included. A '*' can be used as a wildcard
|
/// If this list is absent then all event types are included. A '*' can be used as a wildcard
|
||||||
/// to match any sequence of characters.
|
/// to match any sequence of characters.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub types: Option<&'a [String]>,
|
pub types: Option<Vec<String>>,
|
||||||
|
|
||||||
/// A list of sender IDs to exclude.
|
/// A list of sender IDs to exclude.
|
||||||
///
|
///
|
||||||
/// If this list is absent then no senders are excluded. A matching sender will be excluded
|
/// If this list is absent then no senders are excluded. A matching sender will be excluded
|
||||||
/// even if it is listed in the 'senders' filter.
|
/// even if it is listed in the 'senders' filter.
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub not_senders: &'a [OwnedUserId],
|
pub not_senders: Vec<OwnedUserId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Filter<'a> {
|
impl Filter {
|
||||||
/// Creates an empty `Filter`.
|
/// Creates an empty `Filter`.
|
||||||
///
|
///
|
||||||
/// You can also use the [`Default`] implementation.
|
/// You can also use the [`Default`] implementation.
|
||||||
@ -282,7 +247,7 @@ impl<'a> Filter<'a> {
|
|||||||
|
|
||||||
/// Creates a new `Filter` that can be used to ignore all events.
|
/// Creates a new `Filter` that can be used to ignore all events.
|
||||||
pub fn ignore_all() -> Self {
|
pub fn ignore_all() -> Self {
|
||||||
Self { types: Some(&[]), ..Default::default() }
|
Self { types: Some(vec![]), ..Default::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if all fields are empty.
|
/// Returns `true` if all fields are empty.
|
||||||
@ -295,22 +260,10 @@ impl<'a> Filter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncomingFilter {
|
|
||||||
/// Returns `true` if all fields are empty.
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.not_types.is_empty()
|
|
||||||
&& self.limit.is_none()
|
|
||||||
&& self.senders.is_none()
|
|
||||||
&& self.types.is_none()
|
|
||||||
&& self.not_senders.is_empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A filter definition
|
/// A filter definition
|
||||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(Clone, Default, Serialize)]
|
pub struct FilterDefinition {
|
||||||
pub struct FilterDefinition<'a> {
|
|
||||||
/// List of event fields to include.
|
/// List of event fields to include.
|
||||||
///
|
///
|
||||||
/// If this list is absent then all fields are included. The entries may include '.' characters
|
/// If this list is absent then all fields are included. The entries may include '.' characters
|
||||||
@ -318,7 +271,7 @@ pub struct FilterDefinition<'a> {
|
|||||||
/// object. A literal '.' character in a field name may be escaped using a '\'. A server may
|
/// object. A literal '.' character in a field name may be escaped using a '\'. A server may
|
||||||
/// include more fields than were requested.
|
/// include more fields than were requested.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub event_fields: Option<&'a [String]>,
|
pub event_fields: Option<Vec<String>>,
|
||||||
|
|
||||||
/// The format to use for events.
|
/// The format to use for events.
|
||||||
///
|
///
|
||||||
@ -329,18 +282,18 @@ pub struct FilterDefinition<'a> {
|
|||||||
|
|
||||||
/// The presence updates to include.
|
/// The presence updates to include.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub presence: Filter<'a>,
|
pub presence: Filter,
|
||||||
|
|
||||||
/// The user account data that isn't associated with rooms to include.
|
/// The user account data that isn't associated with rooms to include.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub account_data: Filter<'a>,
|
pub account_data: Filter,
|
||||||
|
|
||||||
/// Filters to be applied to room data.
|
/// Filters to be applied to room data.
|
||||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||||
pub room: RoomFilter<'a>,
|
pub room: RoomFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FilterDefinition<'a> {
|
impl FilterDefinition {
|
||||||
/// Creates an empty `FilterDefinition`.
|
/// Creates an empty `FilterDefinition`.
|
||||||
///
|
///
|
||||||
/// You can also use the [`Default`] implementation.
|
/// You can also use the [`Default`] implementation.
|
||||||
@ -368,20 +321,9 @@ impl<'a> FilterDefinition<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncomingFilterDefinition {
|
|
||||||
/// Returns `true` if all fields are empty.
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.event_fields.is_none()
|
|
||||||
&& self.event_format == EventFormat::Client
|
|
||||||
&& self.presence.is_empty()
|
|
||||||
&& self.account_data.is_empty()
|
|
||||||
&& self.room.is_empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! can_be_empty {
|
macro_rules! can_be_empty {
|
||||||
($ty:ident $(<$gen:tt>)?) => {
|
($ty:ident) => {
|
||||||
impl $(<$gen>)? ruma_common::serde::CanBeEmpty for $ty $(<$gen>)? {
|
impl ruma_common::serde::CanBeEmpty for $ty {
|
||||||
fn is_empty(&self) -> bool {
|
fn is_empty(&self) -> bool {
|
||||||
self.is_empty()
|
self.is_empty()
|
||||||
}
|
}
|
||||||
@ -389,15 +331,10 @@ macro_rules! can_be_empty {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
can_be_empty!(Filter<'a>);
|
can_be_empty!(Filter);
|
||||||
can_be_empty!(FilterDefinition<'a>);
|
can_be_empty!(FilterDefinition);
|
||||||
can_be_empty!(RoomEventFilter<'a>);
|
can_be_empty!(RoomEventFilter);
|
||||||
can_be_empty!(RoomFilter<'a>);
|
can_be_empty!(RoomFilter);
|
||||||
|
|
||||||
can_be_empty!(IncomingFilter);
|
|
||||||
can_be_empty!(IncomingFilterDefinition);
|
|
||||||
can_be_empty!(IncomingRoomEventFilter);
|
|
||||||
can_be_empty!(IncomingRoomFilter);
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
@ -405,8 +342,7 @@ mod tests {
|
|||||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Filter, FilterDefinition, IncomingFilterDefinition, IncomingRoomEventFilter,
|
Filter, FilterDefinition, LazyLoadOptions, RoomEventFilter, RoomFilter, UrlFilter,
|
||||||
IncomingRoomFilter, LazyLoadOptions, RoomEventFilter, RoomFilter, UrlFilter,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -424,7 +360,7 @@ mod tests {
|
|||||||
let filter = FilterDefinition::default();
|
let filter = FilterDefinition::default();
|
||||||
let filter_str = to_json_value(&filter)?;
|
let filter_str = to_json_value(&filter)?;
|
||||||
|
|
||||||
let incoming_filter = from_json_value::<IncomingFilterDefinition>(filter_str)?;
|
let incoming_filter = from_json_value::<FilterDefinition>(filter_str)?;
|
||||||
assert!(incoming_filter.is_empty());
|
assert!(incoming_filter.is_empty());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -435,7 +371,7 @@ mod tests {
|
|||||||
let filter = RoomFilter::default();
|
let filter = RoomFilter::default();
|
||||||
let room_filter = to_json_value(filter)?;
|
let room_filter = to_json_value(filter)?;
|
||||||
|
|
||||||
let incoming_room_filter = from_json_value::<IncomingRoomFilter>(room_filter)?;
|
let incoming_room_filter = from_json_value::<RoomFilter>(room_filter)?;
|
||||||
assert!(incoming_room_filter.is_empty());
|
assert!(incoming_room_filter.is_empty());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -455,7 +391,7 @@ mod tests {
|
|||||||
"contains_url": true,
|
"contains_url": true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let filter: IncomingRoomEventFilter = assert_matches!(from_json_value(obj), Ok(f) => f);
|
let filter: RoomEventFilter = assert_matches!(from_json_value(obj), Ok(f) => f);
|
||||||
|
|
||||||
assert_eq!(filter.types, Some(vec!["m.room.message".to_owned()]));
|
assert_eq!(filter.types, Some(vec!["m.room.message".to_owned()]));
|
||||||
assert_eq!(filter.not_types, vec![""; 0]);
|
assert_eq!(filter.not_types, vec![""; 0]);
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, UserId,
|
metadata, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::filter::{FilterDefinition, IncomingFilterDefinition};
|
use crate::filter::FilterDefinition;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,16 +26,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `create_filter` endpoint.
|
/// Request type for the `create_filter` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The ID of the user uploading the filter.
|
/// The ID of the user uploading the filter.
|
||||||
///
|
///
|
||||||
/// The access token must be authorized to make requests for this user ID.
|
/// The access token must be authorized to make requests for this user ID.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The filter definition.
|
/// The filter definition.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub filter: FilterDefinition<'a>,
|
pub filter: FilterDefinition,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `create_filter` endpoint.
|
/// Response type for the `create_filter` endpoint.
|
||||||
@ -45,9 +45,9 @@ pub mod v3 {
|
|||||||
pub filter_id: String,
|
pub filter_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID and filter definition.
|
/// Creates a new `Request` with the given user ID and filter definition.
|
||||||
pub fn new(user_id: &'a UserId, filter: FilterDefinition<'a>) -> Self {
|
pub fn new(user_id: OwnedUserId, filter: FilterDefinition) -> Self {
|
||||||
Self { user_id, filter }
|
Self { user_id, filter }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,9 +66,9 @@ pub mod v3 {
|
|||||||
fn deserialize_request() {
|
fn deserialize_request() {
|
||||||
use ruma_common::api::IncomingRequest as _;
|
use ruma_common::api::IncomingRequest as _;
|
||||||
|
|
||||||
use super::IncomingRequest;
|
use super::Request;
|
||||||
|
|
||||||
let req = IncomingRequest::try_from_http_request(
|
let req = Request::try_from_http_request(
|
||||||
http::Request::builder()
|
http::Request::builder()
|
||||||
.method(http::Method::POST)
|
.method(http::Method::POST)
|
||||||
.uri("https://matrix.org/_matrix/client/r0/user/@foo:bar.com/filter")
|
.uri("https://matrix.org/_matrix/client/r0/user/@foo:bar.com/filter")
|
||||||
@ -92,13 +92,16 @@ pub mod v3 {
|
|||||||
|
|
||||||
use crate::filter::FilterDefinition;
|
use crate::filter::FilterDefinition;
|
||||||
|
|
||||||
let req = super::Request::new(user_id!("@foo:bar.com"), FilterDefinition::default())
|
let req = super::Request::new(
|
||||||
.try_into_http_request::<Vec<u8>>(
|
user_id!("@foo:bar.com").to_owned(),
|
||||||
"https://matrix.org",
|
FilterDefinition::default(),
|
||||||
SendAccessToken::IfRequired("tok"),
|
)
|
||||||
&[MatrixVersion::V1_1],
|
.try_into_http_request::<Vec<u8>>(
|
||||||
)
|
"https://matrix.org",
|
||||||
.unwrap();
|
SendAccessToken::IfRequired("tok"),
|
||||||
|
&[MatrixVersion::V1_1],
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
assert_eq!(req.body(), b"{}");
|
assert_eq!(req.body(), b"{}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, UserId,
|
metadata, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::filter::IncomingFilterDefinition;
|
use crate::filter::FilterDefinition;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
@ -26,14 +26,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_filter` endpoint.
|
/// Request type for the `get_filter` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user ID to download a filter for.
|
/// The user ID to download a filter for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The ID of the filter to download.
|
/// The ID of the filter to download.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub filter_id: &'a str,
|
pub filter_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_filter` endpoint.
|
/// Response type for the `get_filter` endpoint.
|
||||||
@ -41,19 +41,19 @@ pub mod v3 {
|
|||||||
pub struct Response {
|
pub struct Response {
|
||||||
/// The filter definition.
|
/// The filter definition.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub filter: IncomingFilterDefinition,
|
pub filter: FilterDefinition,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID and filter ID.
|
/// Creates a new `Request` with the given user ID and filter ID.
|
||||||
pub fn new(user_id: &'a UserId, filter_id: &'a str) -> Self {
|
pub fn new(user_id: OwnedUserId, filter_id: String) -> Self {
|
||||||
Self { user_id, filter_id }
|
Self { user_id, filter_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given filter definition.
|
/// Creates a new `Response` with the given filter definition.
|
||||||
pub fn new(filter: IncomingFilterDefinition) -> Self {
|
pub fn new(filter: FilterDefinition) -> Self {
|
||||||
Self { filter }
|
Self { filter }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,9 +77,9 @@ pub mod v3 {
|
|||||||
fn serialize_response() {
|
fn serialize_response() {
|
||||||
use ruma_common::api::OutgoingResponse;
|
use ruma_common::api::OutgoingResponse;
|
||||||
|
|
||||||
use crate::filter::IncomingFilterDefinition;
|
use crate::filter::FilterDefinition;
|
||||||
|
|
||||||
let res = super::Response::new(IncomingFilterDefinition::default())
|
let res = super::Response::new(FilterDefinition::default())
|
||||||
.try_into_http_response::<Vec<u8>>()
|
.try_into_http_response::<Vec<u8>>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(res.body(), b"{}");
|
assert_eq!(res.body(), b"{}");
|
||||||
|
@ -24,19 +24,19 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_key_changes` endpoint.
|
/// Request type for the `get_key_changes` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The desired start point of the list.
|
/// The desired start point of the list.
|
||||||
///
|
///
|
||||||
/// Should be the next_batch field from a response to an earlier call to /sync.
|
/// Should be the next_batch field from a response to an earlier call to /sync.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub from: &'a str,
|
pub from: String,
|
||||||
|
|
||||||
/// The desired end point of the list.
|
/// The desired end point of the list.
|
||||||
///
|
///
|
||||||
/// Should be the next_batch field from a recent call to /sync - typically the most recent
|
/// Should be the next_batch field from a recent call to /sync - typically the most recent
|
||||||
/// such call.
|
/// such call.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub to: &'a str,
|
pub to: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_key_changes` endpoint.
|
/// Response type for the `get_key_changes` endpoint.
|
||||||
@ -50,9 +50,9 @@ pub mod v3 {
|
|||||||
pub left: Vec<OwnedUserId>,
|
pub left: Vec<OwnedUserId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given start and end points.
|
/// Creates a new `Request` with the given start and end points.
|
||||||
pub fn new(from: &'a str, to: &'a str) -> Self {
|
pub fn new(from: String, to: String) -> Self {
|
||||||
Self { from, to }
|
Self { from, to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ pub mod v3 {
|
|||||||
/// Request type for the `get_keys` endpoint.
|
/// Request type for the `get_keys` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The time (in milliseconds) to wait when downloading keys from remote servers.
|
/// The time (in milliseconds) to wait when downloading keys from remote servers.
|
||||||
///
|
///
|
||||||
/// 10 seconds is the recommended default.
|
/// 10 seconds is the recommended default.
|
||||||
@ -54,7 +54,7 @@ pub mod v3 {
|
|||||||
/// This allows the server to ensure its response contains the keys advertised by the
|
/// This allows the server to ensure its response contains the keys advertised by the
|
||||||
/// notification in that sync.
|
/// notification in that sync.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub token: Option<&'a str>,
|
pub token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_keys` endpoint.
|
/// Response type for the `get_keys` endpoint.
|
||||||
@ -84,7 +84,7 @@ pub mod v3 {
|
|||||||
pub user_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
|
pub user_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request {
|
||||||
/// Creates an empty `Request`.
|
/// Creates an empty `Request`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
|||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
use crate::uiaa::{AuthData, UiaaResponse};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -29,10 +29,10 @@ pub mod v3 {
|
|||||||
/// Request type for the `upload_signing_keys` endpoint.
|
/// Request type for the `upload_signing_keys` endpoint.
|
||||||
#[request(error = UiaaResponse)]
|
#[request(error = UiaaResponse)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData>,
|
||||||
|
|
||||||
/// The user's master key.
|
/// The user's master key.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -58,7 +58,7 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request {
|
||||||
/// Creates an empty `Request`.
|
/// Creates an empty `Request`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedRoomId, OwnedServerName, RoomOrAliasId,
|
metadata, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,21 +24,21 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `knock_room` endpoint.
|
/// Request type for the `knock_room` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room the user should knock on.
|
/// The room the user should knock on.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id_or_alias: &'a RoomOrAliasId,
|
pub room_id_or_alias: OwnedRoomOrAliasId,
|
||||||
|
|
||||||
/// The reason for joining a room.
|
/// The reason for joining a room.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
|
|
||||||
/// The servers to attempt to knock on the room through.
|
/// The servers to attempt to knock on the room through.
|
||||||
///
|
///
|
||||||
/// One of the servers must be participating in the room.
|
/// One of the servers must be participating in the room.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub server_name: &'a [OwnedServerName],
|
pub server_name: Vec<OwnedServerName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `knock_room` endpoint.
|
/// Response type for the `knock_room` endpoint.
|
||||||
@ -48,10 +48,10 @@ pub mod v3 {
|
|||||||
pub room_id: OwnedRoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID or alias.
|
/// Creates a new `Request` with the given room ID or alias.
|
||||||
pub fn new(room_id_or_alias: &'a RoomOrAliasId) -> Self {
|
pub fn new(room_id_or_alias: OwnedRoomOrAliasId) -> Self {
|
||||||
Self { room_id_or_alias, reason: None, server_name: &[] }
|
Self { room_id_or_alias, reason: None, server_name: vec![] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,19 +25,15 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `create_media_content` endpoint.
|
/// Request type for the `create_media_content` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The file contents to upload.
|
|
||||||
#[ruma_api(raw_body)]
|
|
||||||
pub file: &'a [u8],
|
|
||||||
|
|
||||||
/// The name of the file being uploaded.
|
/// The name of the file being uploaded.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub filename: Option<&'a str>,
|
pub filename: Option<String>,
|
||||||
|
|
||||||
/// The content type of the file being uploaded.
|
/// The content type of the file being uploaded.
|
||||||
#[ruma_api(header = CONTENT_TYPE)]
|
#[ruma_api(header = CONTENT_TYPE)]
|
||||||
pub content_type: Option<&'a str>,
|
pub content_type: Option<String>,
|
||||||
|
|
||||||
/// Should the server return a blurhash or not.
|
/// Should the server return a blurhash or not.
|
||||||
///
|
///
|
||||||
@ -51,6 +47,10 @@ pub mod v3 {
|
|||||||
rename = "xyz.amorgan.generate_blurhash"
|
rename = "xyz.amorgan.generate_blurhash"
|
||||||
)]
|
)]
|
||||||
pub generate_blurhash: bool,
|
pub generate_blurhash: bool,
|
||||||
|
|
||||||
|
/// The file contents to upload.
|
||||||
|
#[ruma_api(raw_body)]
|
||||||
|
pub file: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `create_media_content` endpoint.
|
/// Response type for the `create_media_content` endpoint.
|
||||||
@ -72,9 +72,9 @@ pub mod v3 {
|
|||||||
pub blurhash: Option<String>,
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given file contents.
|
/// Creates a new `Request` with the given file contents.
|
||||||
pub fn new(file: &'a [u8]) -> Self {
|
pub fn new(file: Vec<u8>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
file,
|
file,
|
||||||
filename: None,
|
filename: None,
|
||||||
|
@ -10,7 +10,7 @@ pub mod unstable {
|
|||||||
use http::header::CONTENT_TYPE;
|
use http::header::CONTENT_TYPE;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, IdParseError, MxcUri, ServerName,
|
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,22 +24,22 @@ pub mod unstable {
|
|||||||
|
|
||||||
/// Request type for the `create_content_async` endpoint.
|
/// Request type for the `create_content_async` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The server name from the mxc:// URI (the authoritory component).
|
/// The server name from the mxc:// URI (the authoritory component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub server_name: &'a ServerName,
|
pub server_name: OwnedServerName,
|
||||||
|
|
||||||
/// The media ID from the mxc:// URI (the path component).
|
/// The media ID from the mxc:// URI (the path component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub media_id: &'a str,
|
pub media_id: String,
|
||||||
|
|
||||||
/// The file contents to upload.
|
/// The file contents to upload.
|
||||||
#[ruma_api(raw_body)]
|
#[ruma_api(raw_body)]
|
||||||
pub file: &'a [u8],
|
pub file: Vec<u8>,
|
||||||
|
|
||||||
/// The content type of the file being uploaded.
|
/// The content type of the file being uploaded.
|
||||||
#[ruma_api(header = CONTENT_TYPE)]
|
#[ruma_api(header = CONTENT_TYPE)]
|
||||||
pub content_type: Option<&'a str>,
|
pub content_type: Option<String>,
|
||||||
// TODO: How does this and msc2448 (blurhash) interact?
|
// TODO: How does this and msc2448 (blurhash) interact?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,16 +47,16 @@ pub mod unstable {
|
|||||||
#[response(error = crate::Error)]
|
#[response(error = crate::Error)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given file contents.
|
/// Creates a new `Request` with the given file contents.
|
||||||
pub fn new(media_id: &'a str, server_name: &'a ServerName, file: &'a [u8]) -> Self {
|
pub fn new(media_id: String, server_name: OwnedServerName, file: Vec<u8>) -> Self {
|
||||||
Self { media_id, server_name, file, content_type: None }
|
Self { media_id, server_name, file, content_type: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` with the given url and file contents.
|
/// Creates a new `Request` with the given url and file contents.
|
||||||
pub fn from_url(url: &'a MxcUri, file: &'a [u8]) -> Result<Self, IdParseError> {
|
pub fn from_url(url: &MxcUri, file: Vec<u8>) -> Result<Self, IdParseError> {
|
||||||
let (server_name, media_id) = url.parts()?;
|
let (server_name, media_id) = url.parts()?;
|
||||||
Ok(Self::new(media_id, server_name, file))
|
Ok(Self::new(media_id.to_owned(), server_name.to_owned(), file))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, IdParseError, MxcUri, ServerName,
|
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
||||||
@ -29,14 +29,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_media_content` endpoint.
|
/// Request type for the `get_media_content` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The server name from the mxc:// URI (the authoritory component).
|
/// The server name from the mxc:// URI (the authoritory component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub server_name: &'a ServerName,
|
pub server_name: OwnedServerName,
|
||||||
|
|
||||||
/// The media ID from the mxc:// URI (the path component).
|
/// The media ID from the mxc:// URI (the path component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub media_id: &'a str,
|
pub media_id: String,
|
||||||
|
|
||||||
/// Whether to fetch media deemed remote.
|
/// Whether to fetch media deemed remote.
|
||||||
///
|
///
|
||||||
@ -91,9 +91,9 @@ pub mod v3 {
|
|||||||
pub cross_origin_resource_policy: Option<String>,
|
pub cross_origin_resource_policy: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given media ID and server name.
|
/// Creates a new `Request` with the given media ID and server name.
|
||||||
pub fn new(media_id: &'a str, server_name: &'a ServerName) -> Self {
|
pub fn new(media_id: String, server_name: OwnedServerName) -> Self {
|
||||||
Self {
|
Self {
|
||||||
media_id,
|
media_id,
|
||||||
server_name,
|
server_name,
|
||||||
@ -104,10 +104,10 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` with the given url.
|
/// Creates a new `Request` with the given url.
|
||||||
pub fn from_url(url: &'a MxcUri) -> Result<Self, IdParseError> {
|
pub fn from_url(url: &MxcUri) -> Result<Self, IdParseError> {
|
||||||
let (server_name, media_id) = url.parts()?;
|
let (server_name, media_id) = url.parts()?;
|
||||||
|
|
||||||
Ok(Self::new(media_id, server_name))
|
Ok(Self::new(media_id.to_owned(), server_name.to_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
|||||||
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
|
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, IdParseError, MxcUri, ServerName,
|
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
||||||
@ -27,18 +27,18 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_media_content_as_filename` endpoint.
|
/// Request type for the `get_media_content_as_filename` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The server name from the mxc:// URI (the authoritory component).
|
/// The server name from the mxc:// URI (the authoritory component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub server_name: &'a ServerName,
|
pub server_name: OwnedServerName,
|
||||||
|
|
||||||
/// The media ID from the mxc:// URI (the path component).
|
/// The media ID from the mxc:// URI (the path component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub media_id: &'a str,
|
pub media_id: String,
|
||||||
|
|
||||||
/// The filename to return in the `Content-Disposition` header.
|
/// The filename to return in the `Content-Disposition` header.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub filename: &'a str,
|
pub filename: String,
|
||||||
|
|
||||||
/// Whether to fetch media deemed remote.
|
/// Whether to fetch media deemed remote.
|
||||||
///
|
///
|
||||||
@ -80,17 +80,22 @@ pub mod v3 {
|
|||||||
pub cross_origin_resource_policy: Option<String>,
|
pub cross_origin_resource_policy: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given media ID, server name and filename.
|
/// Creates a new `Request` with the given media ID, server name and filename.
|
||||||
pub fn new(media_id: &'a str, server_name: &'a ServerName, filename: &'a str) -> Self {
|
pub fn new(media_id: String, server_name: OwnedServerName, filename: String) -> Self {
|
||||||
Self { media_id, server_name, filename, allow_remote: true }
|
Self { media_id, server_name, filename, allow_remote: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` with the given url and filename.
|
/// Creates a new `Request` with the given url and filename.
|
||||||
pub fn from_url(url: &'a MxcUri, filename: &'a str) -> Result<Self, IdParseError> {
|
pub fn from_url(url: &MxcUri, filename: String) -> Result<Self, IdParseError> {
|
||||||
let (server_name, media_id) = url.parts()?;
|
let (server_name, media_id) = url.parts()?;
|
||||||
|
|
||||||
Ok(Self { media_id, server_name, filename, allow_remote: true })
|
Ok(Self {
|
||||||
|
media_id: media_id.to_owned(),
|
||||||
|
server_name: server_name.to_owned(),
|
||||||
|
filename,
|
||||||
|
allow_remote: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
serde::StringEnum,
|
serde::StringEnum,
|
||||||
IdParseError, MxcUri, ServerName,
|
IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{http_headers::CROSS_ORIGIN_RESOURCE_POLICY, PrivOwnedStr};
|
use crate::{http_headers::CROSS_ORIGIN_RESOURCE_POLICY, PrivOwnedStr};
|
||||||
@ -30,14 +30,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_content_thumbnail` endpoint.
|
/// Request type for the `get_content_thumbnail` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The server name from the mxc:// URI (the authoritory component).
|
/// The server name from the mxc:// URI (the authoritory component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub server_name: &'a ServerName,
|
pub server_name: OwnedServerName,
|
||||||
|
|
||||||
/// The media ID from the mxc:// URI (the path component).
|
/// The media ID from the mxc:// URI (the path component).
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub media_id: &'a str,
|
pub media_id: String,
|
||||||
|
|
||||||
/// The desired resizing method.
|
/// The desired resizing method.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
@ -100,12 +100,12 @@ pub mod v3 {
|
|||||||
pub cross_origin_resource_policy: Option<String>,
|
pub cross_origin_resource_policy: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given media ID, server name, desired thumbnail width
|
/// Creates a new `Request` with the given media ID, server name, desired thumbnail width
|
||||||
/// and desired thumbnail height.
|
/// and desired thumbnail height.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
media_id: &'a str,
|
media_id: String,
|
||||||
server_name: &'a ServerName,
|
server_name: OwnedServerName,
|
||||||
width: UInt,
|
width: UInt,
|
||||||
height: UInt,
|
height: UInt,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -123,10 +123,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Creates a new `Request` with the given url, desired thumbnail width and
|
/// Creates a new `Request` with the given url, desired thumbnail width and
|
||||||
/// desired thumbnail height.
|
/// desired thumbnail height.
|
||||||
pub fn from_url(url: &'a MxcUri, width: UInt, height: UInt) -> Result<Self, IdParseError> {
|
pub fn from_url(url: &MxcUri, width: UInt, height: UInt) -> Result<Self, IdParseError> {
|
||||||
let (server_name, media_id) = url.parts()?;
|
let (server_name, media_id) = url.parts()?;
|
||||||
|
|
||||||
Ok(Self::new(media_id, server_name, width, height))
|
Ok(Self::new(media_id.to_owned(), server_name.to_owned(), width, height))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_media_preview` endpoint.
|
/// Request type for the `get_media_preview` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// URL to get a preview of.
|
/// URL to get a preview of.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub url: &'a str,
|
pub url: String,
|
||||||
|
|
||||||
/// Preferred point in time (in milliseconds) to return a preview for.
|
/// Preferred point in time (in milliseconds) to return a preview for.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
@ -48,9 +48,9 @@ pub mod v3 {
|
|||||||
pub data: Option<Box<RawJsonValue>>,
|
pub data: Option<Box<RawJsonValue>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given url and timestamp.
|
/// Creates a new `Request` with the given url and timestamp.
|
||||||
pub fn new(url: &'a str, ts: MilliSecondsSinceUnixEpoch) -> Self {
|
pub fn new(url: String, ts: MilliSecondsSinceUnixEpoch) -> Self {
|
||||||
Self { url, ts }
|
Self { url, ts }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,36 +16,34 @@ pub mod unban_user;
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{thirdparty::Medium, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId};
|
||||||
serde::Incoming, thirdparty::Medium, OwnedServerName, OwnedServerSigningKeyId, UserId,
|
use serde::{Deserialize, Serialize};
|
||||||
};
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party
|
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party
|
||||||
/// identity which has been invited to the room.
|
/// identity which has been invited to the room.
|
||||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct ThirdPartySigned<'a> {
|
pub struct ThirdPartySigned {
|
||||||
/// The Matrix ID of the user who issued the invite.
|
/// The Matrix ID of the user who issued the invite.
|
||||||
pub sender: &'a UserId,
|
pub sender: OwnedUserId,
|
||||||
|
|
||||||
/// The Matrix ID of the invitee.
|
/// The Matrix ID of the invitee.
|
||||||
pub mxid: &'a UserId,
|
pub mxid: OwnedUserId,
|
||||||
|
|
||||||
/// The state key of the `m.third_party_invite` event.
|
/// The state key of the `m.third_party_invite` event.
|
||||||
pub token: &'a str,
|
pub token: String,
|
||||||
|
|
||||||
/// A signatures object containing a signature of the entire signed object.
|
/// A signatures object containing a signature of the entire signed object.
|
||||||
pub signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
|
pub signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ThirdPartySigned<'a> {
|
impl ThirdPartySigned {
|
||||||
/// Creates a new `ThirdPartySigned` from the given sender and invitee user IDs, state key token
|
/// Creates a new `ThirdPartySigned` from the given sender and invitee user IDs, state key token
|
||||||
/// and signatures.
|
/// and signatures.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
sender: &'a UserId,
|
sender: OwnedUserId,
|
||||||
mxid: &'a UserId,
|
mxid: OwnedUserId,
|
||||||
token: &'a str,
|
token: String,
|
||||||
signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
|
signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { sender, mxid, token, signatures }
|
Self { sender, mxid, token, signatures }
|
||||||
@ -56,20 +54,20 @@ impl<'a> ThirdPartySigned<'a> {
|
|||||||
///
|
///
|
||||||
/// To create an instance of this type, first create a `Invite3pidInit` and convert it via
|
/// To create an instance of this type, first create a `Invite3pidInit` and convert it via
|
||||||
/// `Invite3pid::from` / `.into()`.
|
/// `Invite3pid::from` / `.into()`.
|
||||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct Invite3pid<'a> {
|
pub struct Invite3pid {
|
||||||
/// Hostname and port of identity server to be used for account lookups.
|
/// Hostname and port of identity server to be used for account lookups.
|
||||||
pub id_server: &'a str,
|
pub id_server: String,
|
||||||
|
|
||||||
/// An access token registered with the identity server.
|
/// An access token registered with the identity server.
|
||||||
pub id_access_token: &'a str,
|
pub id_access_token: String,
|
||||||
|
|
||||||
/// Type of third party ID.
|
/// Type of third party ID.
|
||||||
pub medium: Medium,
|
pub medium: Medium,
|
||||||
|
|
||||||
/// Third party identifier.
|
/// Third party identifier.
|
||||||
pub address: &'a str,
|
pub address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initial set of fields of `Invite3pid`.
|
/// Initial set of fields of `Invite3pid`.
|
||||||
@ -78,22 +76,22 @@ pub struct Invite3pid<'a> {
|
|||||||
/// (non-breaking) release of the Matrix specification.
|
/// (non-breaking) release of the Matrix specification.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(clippy::exhaustive_structs)]
|
#[allow(clippy::exhaustive_structs)]
|
||||||
pub struct Invite3pidInit<'a> {
|
pub struct Invite3pidInit {
|
||||||
/// Hostname and port of identity server to be used for account lookups.
|
/// Hostname and port of identity server to be used for account lookups.
|
||||||
pub id_server: &'a str,
|
pub id_server: String,
|
||||||
|
|
||||||
/// An access token registered with the identity server.
|
/// An access token registered with the identity server.
|
||||||
pub id_access_token: &'a str,
|
pub id_access_token: String,
|
||||||
|
|
||||||
/// Type of third party ID.
|
/// Type of third party ID.
|
||||||
pub medium: Medium,
|
pub medium: Medium,
|
||||||
|
|
||||||
/// Third party identifier.
|
/// Third party identifier.
|
||||||
pub address: &'a str,
|
pub address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<Invite3pidInit<'a>> for Invite3pid<'a> {
|
impl From<Invite3pidInit> for Invite3pid {
|
||||||
fn from(init: Invite3pidInit<'a>) -> Self {
|
fn from(init: Invite3pidInit) -> Self {
|
||||||
let Invite3pidInit { id_server, id_access_token, medium, address } = init;
|
let Invite3pidInit { id_server, id_access_token, medium, address } = init;
|
||||||
Self { id_server, id_access_token, medium, address }
|
Self { id_server, id_access_token, medium, address }
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId, UserId,
|
metadata, OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,17 +24,17 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `ban_user` endpoint.
|
/// Request type for the `ban_user` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to kick the user from.
|
/// The room to kick the user from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The user to ban.
|
/// The user to ban.
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The reason for banning the user.
|
/// The reason for banning the user.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `ban_user` endpoint.
|
/// Response type for the `ban_user` endpoint.
|
||||||
@ -42,9 +42,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id and room id.
|
/// Creates a new `Request` with the given room id and room id.
|
||||||
pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self {
|
pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
|
||||||
Self { room_id, user_id, reason: None }
|
Self { room_id, user_id, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `forget_room` endpoint.
|
/// Request type for the `forget_room` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to forget.
|
/// The room to forget.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `forget_room` endpoint.
|
/// Response type for the `forget_room` endpoint.
|
||||||
@ -35,9 +35,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id.
|
/// Creates a new `Request` with the given room id.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id }
|
Self { room_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
events::room::member::RoomMemberEvent,
|
events::room::member::RoomMemberEvent,
|
||||||
metadata,
|
metadata,
|
||||||
serde::{Raw, StringEnum},
|
serde::{Raw, StringEnum},
|
||||||
RoomId,
|
OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::PrivOwnedStr;
|
use crate::PrivOwnedStr;
|
||||||
@ -29,10 +29,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_member_events` endpoint.
|
/// Request type for the `get_member_events` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to get the member events for.
|
/// The room to get the member events for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The point in time (pagination token) to return members for in the room.
|
/// The point in time (pagination token) to return members for in the room.
|
||||||
///
|
///
|
||||||
@ -40,7 +40,7 @@ pub mod v3 {
|
|||||||
/// API.
|
/// API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub at: Option<&'a str>,
|
pub at: Option<String>,
|
||||||
|
|
||||||
/// The kind of memberships to filter for.
|
/// The kind of memberships to filter for.
|
||||||
///
|
///
|
||||||
@ -66,9 +66,9 @@ pub mod v3 {
|
|||||||
pub chunk: Vec<Raw<RoomMemberEvent>>,
|
pub chunk: Vec<Raw<RoomMemberEvent>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID.
|
/// Creates a new `Request` with the given room ID.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id, at: None, membership: None, not_membership: None }
|
Self { room_id, at: None, membership: None, not_membership: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ pub mod v3 {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use ruma_common::api::IncomingRequest as _;
|
use ruma_common::api::IncomingRequest as _;
|
||||||
|
|
||||||
use super::{IncomingRequest, MembershipEventFilter};
|
use super::{MembershipEventFilter, Request};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialization() {
|
fn deserialization() {
|
||||||
@ -121,7 +121,7 @@ pub mod v3 {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let req = IncomingRequest::try_from_http_request(
|
let req = Request::try_from_http_request(
|
||||||
http::Request::builder().uri(uri).body(&[] as &[u8]).unwrap(),
|
http::Request::builder().uri(uri).body(&[] as &[u8]).unwrap(),
|
||||||
&["!dummy:example.org"],
|
&["!dummy:example.org"],
|
||||||
)
|
)
|
||||||
|
@ -14,13 +14,11 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata, OwnedRoomId, OwnedUserId,
|
||||||
serde::Incoming,
|
|
||||||
RoomId, UserId,
|
|
||||||
};
|
};
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::membership::{IncomingInvite3pid, Invite3pid};
|
use crate::membership::Invite3pid;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -34,18 +32,18 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `invite_user` endpoint.
|
/// Request type for the `invite_user` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room where the user should be invited.
|
/// The room where the user should be invited.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The user to invite.
|
/// The user to invite.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub recipient: InvitationRecipient<'a>,
|
pub recipient: InvitationRecipient,
|
||||||
|
|
||||||
/// Optional reason for inviting the user.
|
/// Optional reason for inviting the user.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `invite_user` endpoint.
|
/// Response type for the `invite_user` endpoint.
|
||||||
@ -53,9 +51,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID and invitation recipient.
|
/// Creates a new `Request` with the given room ID and invitation recipient.
|
||||||
pub fn new(room_id: &'a RoomId, recipient: InvitationRecipient<'a>) -> Self {
|
pub fn new(room_id: OwnedRoomId, recipient: InvitationRecipient) -> Self {
|
||||||
Self { room_id, recipient, reason: None }
|
Self { room_id, recipient, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,18 +66,18 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Distinguishes between invititations by Matrix or third party identifiers.
|
/// Distinguishes between invititations by Matrix or third party identifiers.
|
||||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum InvitationRecipient<'a> {
|
pub enum InvitationRecipient {
|
||||||
/// Used to invite user by their Matrix identifier.
|
/// Used to invite user by their Matrix identifier.
|
||||||
UserId {
|
UserId {
|
||||||
/// Matrix identifier of user.
|
/// Matrix identifier of user.
|
||||||
user_id: &'a UserId,
|
user_id: OwnedUserId,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Used to invite user by a third party identifier.
|
/// Used to invite user by a third party identifier.
|
||||||
ThirdPartyId(Invite3pid<'a>),
|
ThirdPartyId(Invite3pid),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -88,25 +86,24 @@ pub mod v3 {
|
|||||||
use ruma_common::thirdparty::Medium;
|
use ruma_common::thirdparty::Medium;
|
||||||
use serde_json::{from_value as from_json_value, json};
|
use serde_json::{from_value as from_json_value, json};
|
||||||
|
|
||||||
use super::IncomingInvitationRecipient;
|
use super::InvitationRecipient;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_invite_by_user_id() {
|
fn deserialize_invite_by_user_id() {
|
||||||
let incoming = from_json_value::<IncomingInvitationRecipient>(
|
let incoming =
|
||||||
json!({ "user_id": "@carl:example.org" }),
|
from_json_value::<InvitationRecipient>(json!({ "user_id": "@carl:example.org" }))
|
||||||
)
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let user_id = assert_matches!(
|
let user_id = assert_matches!(
|
||||||
incoming,
|
incoming,
|
||||||
IncomingInvitationRecipient::UserId { user_id } => user_id
|
InvitationRecipient::UserId { user_id } => user_id
|
||||||
);
|
);
|
||||||
assert_eq!(user_id, "@carl:example.org");
|
assert_eq!(user_id, "@carl:example.org");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_invite_by_3pid() {
|
fn deserialize_invite_by_3pid() {
|
||||||
let incoming = from_json_value::<IncomingInvitationRecipient>(json!({
|
let incoming = from_json_value::<InvitationRecipient>(json!({
|
||||||
"id_server": "example.org",
|
"id_server": "example.org",
|
||||||
"id_access_token": "abcdefghijklmnop",
|
"id_access_token": "abcdefghijklmnop",
|
||||||
"medium": "email",
|
"medium": "email",
|
||||||
@ -116,7 +113,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
let third_party_id = assert_matches!(
|
let third_party_id = assert_matches!(
|
||||||
incoming,
|
incoming,
|
||||||
IncomingInvitationRecipient::ThirdPartyId(id) => id
|
InvitationRecipient::ThirdPartyId(id) => id
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(third_party_id.id_server, "example.org");
|
assert_eq!(third_party_id.id_server, "example.org");
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedRoomId, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::membership::{IncomingThirdPartySigned, ThirdPartySigned};
|
use crate::membership::ThirdPartySigned;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,19 +26,19 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `join_room_by_id` endpoint.
|
/// Request type for the `join_room_by_id` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room where the user should be invited.
|
/// The room where the user should be invited.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The signature of a `m.third_party_invite` token to prove that this user owns a third
|
/// 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.
|
/// party identity which has been invited to the room.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub third_party_signed: Option<ThirdPartySigned<'a>>,
|
pub third_party_signed: Option<ThirdPartySigned>,
|
||||||
|
|
||||||
/// Optional reason for joining the room.
|
/// Optional reason for joining the room.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `join_room_by_id` endpoint.
|
/// Response type for the `join_room_by_id` endpoint.
|
||||||
@ -48,9 +48,9 @@ pub mod v3 {
|
|||||||
pub room_id: OwnedRoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id.
|
/// Creates a new `Request` with the given room id.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id, third_party_signed: None, reason: None }
|
Self { room_id, third_party_signed: None, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedRoomId, OwnedServerName, RoomOrAliasId,
|
metadata, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::membership::{IncomingThirdPartySigned, ThirdPartySigned};
|
use crate::membership::ThirdPartySigned;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: POST,
|
method: POST,
|
||||||
@ -26,26 +26,26 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `join_room_by_id_or_alias` endpoint.
|
/// Request type for the `join_room_by_id_or_alias` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room where the user should be invited.
|
/// The room where the user should be invited.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id_or_alias: &'a RoomOrAliasId,
|
pub room_id_or_alias: OwnedRoomOrAliasId,
|
||||||
|
|
||||||
/// The servers to attempt to join the room through.
|
/// The servers to attempt to join the room through.
|
||||||
///
|
///
|
||||||
/// One of the servers must be participating in the room.
|
/// One of the servers must be participating in the room.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||||
pub server_name: &'a [OwnedServerName],
|
pub server_name: Vec<OwnedServerName>,
|
||||||
|
|
||||||
/// The signature of a `m.third_party_invite` token to prove that this user owns a third
|
/// 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.
|
/// party identity which has been invited to the room.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub third_party_signed: Option<ThirdPartySigned<'a>>,
|
pub third_party_signed: Option<ThirdPartySigned>,
|
||||||
|
|
||||||
/// Optional reason for joining the room.
|
/// Optional reason for joining the room.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `join_room_by_id_or_alias` endpoint.
|
/// Response type for the `join_room_by_id_or_alias` endpoint.
|
||||||
@ -55,10 +55,10 @@ pub mod v3 {
|
|||||||
pub room_id: OwnedRoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID or alias ID.
|
/// Creates a new `Request` with the given room ID or alias ID.
|
||||||
pub fn new(room_id_or_alias: &'a RoomOrAliasId) -> Self {
|
pub fn new(room_id_or_alias: OwnedRoomOrAliasId) -> Self {
|
||||||
Self { room_id_or_alias, server_name: &[], third_party_signed: None, reason: None }
|
Self { room_id_or_alias, server_name: vec![], third_party_signed: None, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedMxcUri, OwnedUserId, RoomId,
|
metadata, OwnedMxcUri, OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -28,10 +28,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `joined_members` endpoint.
|
/// Request type for the `joined_members` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to get the members of.
|
/// The room to get the members of.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `joined_members` endpoint.
|
/// Response type for the `joined_members` endpoint.
|
||||||
@ -42,9 +42,9 @@ pub mod v3 {
|
|||||||
pub joined: BTreeMap<OwnedUserId, RoomMember>,
|
pub joined: BTreeMap<OwnedUserId, RoomMember>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID.
|
/// Creates a new `Request` with the given room ID.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id }
|
Self { room_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId, UserId,
|
metadata, OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,17 +24,17 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `kick_user` endpoint.
|
/// Request type for the `kick_user` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to kick the user from.
|
/// The room to kick the user from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The user to kick.
|
/// The user to kick.
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The reason for kicking the user.
|
/// The reason for kicking the user.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `kick_user` endpoint.
|
/// Response type for the `kick_user` endpoint.
|
||||||
@ -42,9 +42,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id and room id.
|
/// Creates a new `Request` with the given room id and room id.
|
||||||
pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self {
|
pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
|
||||||
Self { room_id, user_id, reason: None }
|
Self { room_id, user_id, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId,
|
metadata, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,14 +24,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `leave_room` endpoint.
|
/// Request type for the `leave_room` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to leave.
|
/// The room to leave.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// Optional reason to be included as the `reason` on the subsequent membership event.
|
/// Optional reason to be included as the `reason` on the subsequent membership event.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `leave_room` endpoint.
|
/// Response type for the `leave_room` endpoint.
|
||||||
@ -39,9 +39,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id.
|
/// Creates a new `Request` with the given room id.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id, reason: None }
|
Self { room_id, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod unstable {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedRoomId, UserId,
|
metadata, OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -23,10 +23,10 @@ pub mod unstable {
|
|||||||
|
|
||||||
/// Request type for the `mutual_rooms` endpoint.
|
/// Request type for the `mutual_rooms` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user to search mutual rooms for.
|
/// The user to search mutual rooms for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `mutual_rooms` endpoint.
|
/// Response type for the `mutual_rooms` endpoint.
|
||||||
@ -36,9 +36,9 @@ pub mod unstable {
|
|||||||
pub joined: Vec<OwnedRoomId>,
|
pub joined: Vec<OwnedRoomId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user id.
|
/// Creates a new `Request` with the given user id.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, RoomId, UserId,
|
metadata, OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,17 +24,17 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `unban_user` endpoint.
|
/// Request type for the `unban_user` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to unban the user from.
|
/// The room to unban the user from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The user to unban.
|
/// The user to unban.
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// Optional reason for unbanning the user.
|
/// Optional reason for unbanning the user.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `unban_user` endpoint.
|
/// Response type for the `unban_user` endpoint.
|
||||||
@ -42,9 +42,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id and room id.
|
/// Creates a new `Request` with the given room id and room id.
|
||||||
pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self {
|
pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
|
||||||
Self { room_id, user_id, reason: None }
|
Self { room_id, user_id, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,10 @@ pub mod v3 {
|
|||||||
events::{AnyStateEvent, AnyTimelineEvent},
|
events::{AnyStateEvent, AnyTimelineEvent},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomId,
|
OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{filter::RoomEventFilter, Direction};
|
||||||
filter::{IncomingRoomEventFilter, RoomEventFilter},
|
|
||||||
Direction,
|
|
||||||
};
|
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
@ -33,10 +30,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_message_events` endpoint.
|
/// Request type for the `get_message_events` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to get events from.
|
/// The room to get events from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The token to start returning events from.
|
/// The token to start returning events from.
|
||||||
///
|
///
|
||||||
@ -47,7 +44,7 @@ pub mod v3 {
|
|||||||
/// If this is `None`, the server will return messages from the start or end of the
|
/// If this is `None`, the server will return messages from the start or end of the
|
||||||
/// history visible to the user, depending on the value of [`dir`][Self::dir].
|
/// history visible to the user, depending on the value of [`dir`][Self::dir].
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub from: Option<&'a str>,
|
pub from: Option<String>,
|
||||||
|
|
||||||
/// The token to stop returning events at.
|
/// The token to stop returning events at.
|
||||||
///
|
///
|
||||||
@ -56,7 +53,7 @@ pub mod v3 {
|
|||||||
/// this endpoint.
|
/// this endpoint.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub to: Option<&'a str>,
|
pub to: Option<String>,
|
||||||
|
|
||||||
/// The direction to return events from.
|
/// The direction to return events from.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
@ -76,7 +73,7 @@ pub mod v3 {
|
|||||||
default,
|
default,
|
||||||
skip_serializing_if = "RoomEventFilter::is_empty"
|
skip_serializing_if = "RoomEventFilter::is_empty"
|
||||||
)]
|
)]
|
||||||
pub filter: RoomEventFilter<'a>,
|
pub filter: RoomEventFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_message_events` endpoint.
|
/// Response type for the `get_message_events` endpoint.
|
||||||
@ -99,11 +96,11 @@ pub mod v3 {
|
|||||||
pub state: Vec<Raw<AnyStateEvent>>,
|
pub state: Vec<Raw<AnyStateEvent>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID and direction.
|
/// Creates a new `Request` with the given room ID and direction.
|
||||||
///
|
///
|
||||||
/// All other parameters will be defaulted.
|
/// All other parameters will be defaulted.
|
||||||
pub fn new(room_id: &'a RoomId, dir: Direction) -> Self {
|
pub fn new(room_id: OwnedRoomId, dir: Direction) -> Self {
|
||||||
Self {
|
Self {
|
||||||
room_id,
|
room_id,
|
||||||
from: None,
|
from: None,
|
||||||
@ -123,11 +120,11 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ruma_client_api::message::get_message_events;
|
/// # use ruma_client_api::message::get_message_events;
|
||||||
/// # let room_id = ruma_common::room_id!("!a:example.org");
|
/// # let room_id = ruma_common::room_id!("!a:example.org").to_owned();
|
||||||
/// # let token = "prev_batch token";
|
/// # let token = "prev_batch token".to_owned();
|
||||||
/// let request = get_message_events::v3::Request::backward(room_id).from(token);
|
/// let request = get_message_events::v3::Request::backward(room_id).from(token);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn backward(room_id: &'a RoomId) -> Self {
|
pub fn backward(room_id: OwnedRoomId) -> Self {
|
||||||
Self::new(room_id, Direction::Backward)
|
Self::new(room_id, Direction::Backward)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,11 +137,11 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ruma_client_api::message::get_message_events;
|
/// # use ruma_client_api::message::get_message_events;
|
||||||
/// # let room_id = ruma_common::room_id!("!a:example.org");
|
/// # let room_id = ruma_common::room_id!("!a:example.org").to_owned();
|
||||||
/// # let token = "end token";
|
/// # let token = "end token".to_owned();
|
||||||
/// let request = get_message_events::v3::Request::forward(room_id).from(token);
|
/// let request = get_message_events::v3::Request::forward(room_id).from(token);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn forward(room_id: &'a RoomId) -> Self {
|
pub fn forward(room_id: OwnedRoomId) -> Self {
|
||||||
Self::new(room_id, Direction::Forward)
|
Self::new(room_id, Direction::Forward)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +149,7 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// Since the field is public, you can also assign to it directly. This method merely acts
|
/// Since the field is public, you can also assign to it directly. This method merely acts
|
||||||
/// as a shorthand for that, because it is very common to set this field.
|
/// as a shorthand for that, because it is very common to set this field.
|
||||||
pub fn from(self, from: impl Into<Option<&'a str>>) -> Self {
|
pub fn from(self, from: impl Into<Option<String>>) -> Self {
|
||||||
Self { from: from.into(), ..self }
|
Self { from: from.into(), ..self }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,23 +186,23 @@ pub mod v3 {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_some_room_event_filter() {
|
fn serialize_some_room_event_filter() {
|
||||||
let room_id = room_id!("!roomid:example.org");
|
let room_id = room_id!("!roomid:example.org").to_owned();
|
||||||
let rooms = &[room_id.to_owned()];
|
let rooms = vec![room_id.to_owned()];
|
||||||
let filter = RoomEventFilter {
|
let filter = RoomEventFilter {
|
||||||
lazy_load_options: LazyLoadOptions::Enabled { include_redundant_members: true },
|
lazy_load_options: LazyLoadOptions::Enabled { include_redundant_members: true },
|
||||||
rooms: Some(rooms),
|
rooms: Some(rooms),
|
||||||
not_rooms: &[
|
not_rooms: vec![
|
||||||
room_id!("!room:example.org").to_owned(),
|
room_id!("!room:example.org").to_owned(),
|
||||||
room_id!("!room2:example.org").to_owned(),
|
room_id!("!room2:example.org").to_owned(),
|
||||||
room_id!("!room3:example.org").to_owned(),
|
room_id!("!room3:example.org").to_owned(),
|
||||||
],
|
],
|
||||||
not_types: &["type".into()],
|
not_types: vec!["type".into()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let req = Request {
|
let req = Request {
|
||||||
room_id,
|
room_id,
|
||||||
from: Some("token"),
|
from: Some("token".to_owned()),
|
||||||
to: Some("token2"),
|
to: Some("token2".to_owned()),
|
||||||
dir: Direction::Backward,
|
dir: Direction::Backward,
|
||||||
limit: uint!(0),
|
limit: uint!(0),
|
||||||
filter,
|
filter,
|
||||||
@ -230,11 +227,11 @@ pub mod v3 {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_default_room_event_filter() {
|
fn serialize_default_room_event_filter() {
|
||||||
let room_id = room_id!("!roomid:example.org");
|
let room_id = room_id!("!roomid:example.org").to_owned();
|
||||||
let req = Request {
|
let req = Request {
|
||||||
room_id,
|
room_id,
|
||||||
from: Some("token"),
|
from: Some("token".to_owned()),
|
||||||
to: Some("token2"),
|
to: Some("token2".to_owned()),
|
||||||
dir: Direction::Backward,
|
dir: Direction::Backward,
|
||||||
limit: uint!(0),
|
limit: uint!(0),
|
||||||
filter: RoomEventFilter::default(),
|
filter: RoomEventFilter::default(),
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
events::{AnyMessageLikeEventContent, MessageLikeEventContent, MessageLikeEventType},
|
events::{AnyMessageLikeEventContent, MessageLikeEventContent, MessageLikeEventType},
|
||||||
metadata,
|
metadata,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, TransactionId,
|
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedTransactionId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||||
|
|
||||||
@ -28,10 +28,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `create_message_event` endpoint.
|
/// Request type for the `create_message_event` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room to send the event to.
|
/// The room to send the event to.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The type of event to send.
|
/// The type of event to send.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -47,7 +47,7 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// [access token is refreshed]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
|
/// [access token is refreshed]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub txn_id: &'a TransactionId,
|
pub txn_id: OwnedTransactionId,
|
||||||
|
|
||||||
/// The event content to send.
|
/// The event content to send.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
@ -72,7 +72,7 @@ pub mod v3 {
|
|||||||
pub event_id: OwnedEventId,
|
pub event_id: OwnedEventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room id, transaction id and event content.
|
/// Creates a new `Request` with the given room id, transaction id and event content.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
@ -80,9 +80,9 @@ pub mod v3 {
|
|||||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||||
pub fn new<T>(
|
pub fn new<T>(
|
||||||
room_id: &'a RoomId,
|
room_id: OwnedRoomId,
|
||||||
txn_id: &'a TransactionId,
|
txn_id: OwnedTransactionId,
|
||||||
content: &'a T,
|
content: &T,
|
||||||
) -> serde_json::Result<Self>
|
) -> serde_json::Result<Self>
|
||||||
where
|
where
|
||||||
T: MessageLikeEventContent,
|
T: MessageLikeEventContent,
|
||||||
@ -99,8 +99,8 @@ pub mod v3 {
|
|||||||
/// Creates a new `Request` with the given room id, transaction id, event type and raw event
|
/// Creates a new `Request` with the given room id, transaction id, event type and raw event
|
||||||
/// content.
|
/// content.
|
||||||
pub fn new_raw(
|
pub fn new_raw(
|
||||||
room_id: &'a RoomId,
|
room_id: OwnedRoomId,
|
||||||
txn_id: &'a TransactionId,
|
txn_id: OwnedTransactionId,
|
||||||
event_type: MessageLikeEventType,
|
event_type: MessageLikeEventType,
|
||||||
body: Raw<AnyMessageLikeEventContent>,
|
body: Raw<AnyMessageLikeEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -13,7 +13,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
presence::PresenceState,
|
presence::PresenceState,
|
||||||
UserId,
|
OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -28,10 +28,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_presence` endpoint.
|
/// Request type for the `get_presence` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose presence state will be retrieved.
|
/// The user whose presence state will be retrieved.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_presence` endpoint.
|
/// Response type for the `get_presence` endpoint.
|
||||||
@ -57,9 +57,9 @@ pub mod v3 {
|
|||||||
pub presence: PresenceState,
|
pub presence: PresenceState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID.
|
/// Creates a new `Request` with the given user ID.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
|||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
presence::PresenceState,
|
presence::PresenceState,
|
||||||
UserId,
|
OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -26,17 +26,17 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_presence` endpoint.
|
/// Request type for the `set_presence` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose presence state will be updated.
|
/// The user whose presence state will be updated.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The new presence state.
|
/// The new presence state.
|
||||||
pub presence: PresenceState,
|
pub presence: PresenceState,
|
||||||
|
|
||||||
/// The status message to attach to this state.
|
/// The status message to attach to this state.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub status_msg: Option<&'a str>,
|
pub status_msg: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `set_presence` endpoint.
|
/// Response type for the `set_presence` endpoint.
|
||||||
@ -44,9 +44,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID and presence state.
|
/// Creates a new `Request` with the given user ID and presence state.
|
||||||
pub fn new(user_id: &'a UserId, presence: PresenceState) -> Self {
|
pub fn new(user_id: OwnedUserId, presence: PresenceState) -> Self {
|
||||||
Self { user_id, presence, status_msg: None }
|
Self { user_id, presence, status_msg: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedMxcUri, UserId,
|
metadata, OwnedMxcUri, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_avatar_url` endpoint.
|
/// Request type for the `get_avatar_url` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose avatar URL will be retrieved.
|
/// The user whose avatar URL will be retrieved.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_avatar_url` endpoint.
|
/// Response type for the `get_avatar_url` endpoint.
|
||||||
@ -54,9 +54,9 @@ pub mod v3 {
|
|||||||
pub blurhash: Option<String>,
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID.
|
/// Creates a new `Request` with the given user ID.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, UserId,
|
metadata, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_display_name` endpoint.
|
/// Request type for the `get_display_name` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose display name will be retrieved.
|
/// The user whose display name will be retrieved.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_display_name` endpoint.
|
/// Response type for the `get_display_name` endpoint.
|
||||||
@ -39,9 +39,9 @@ pub mod v3 {
|
|||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID.
|
/// Creates a new `Request` with the given user ID.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, OwnedMxcUri, UserId,
|
metadata, OwnedMxcUri, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_profile` endpoint.
|
/// Request type for the `get_profile` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose profile will be retrieved.
|
/// The user whose profile will be retrieved.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_profile` endpoint.
|
/// Response type for the `get_profile` endpoint.
|
||||||
@ -58,9 +58,9 @@ pub mod v3 {
|
|||||||
pub blurhash: Option<String>,
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID.
|
/// Creates a new `Request` with the given user ID.
|
||||||
pub fn new(user_id: &'a UserId) -> Self {
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
Self { user_id }
|
Self { user_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, MxcUri, UserId,
|
metadata, OwnedMxcUri, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,10 +24,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_avatar_url` endpoint.
|
/// Request type for the `set_avatar_url` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose avatar URL will be set.
|
/// The user whose avatar URL will be set.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The new avatar URL for the user.
|
/// The new avatar URL for the user.
|
||||||
///
|
///
|
||||||
@ -44,7 +44,7 @@ pub mod v3 {
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(not(feature = "compat"), serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(not(feature = "compat"), serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub avatar_url: Option<&'a MxcUri>,
|
pub avatar_url: Option<OwnedMxcUri>,
|
||||||
|
|
||||||
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
||||||
///
|
///
|
||||||
@ -52,7 +52,7 @@ pub mod v3 {
|
|||||||
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
|
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
|
||||||
#[cfg(feature = "unstable-msc2448")]
|
#[cfg(feature = "unstable-msc2448")]
|
||||||
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")]
|
||||||
pub blurhash: Option<&'a str>,
|
pub blurhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `set_avatar_url` endpoint.
|
/// Response type for the `set_avatar_url` endpoint.
|
||||||
@ -60,9 +60,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID and avatar URL.
|
/// Creates a new `Request` with the given user ID and avatar URL.
|
||||||
pub fn new(user_id: &'a UserId, avatar_url: Option<&'a MxcUri>) -> Self {
|
pub fn new(user_id: OwnedUserId, avatar_url: Option<OwnedMxcUri>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
user_id,
|
user_id,
|
||||||
avatar_url,
|
avatar_url,
|
||||||
@ -83,11 +83,11 @@ pub mod v3 {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use ruma_common::api::IncomingRequest as _;
|
use ruma_common::api::IncomingRequest as _;
|
||||||
|
|
||||||
use super::IncomingRequest;
|
use super::Request;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_unset_request() {
|
fn deserialize_unset_request() {
|
||||||
let req = IncomingRequest::try_from_http_request(
|
let req = Request::try_from_http_request(
|
||||||
http::Request::builder()
|
http::Request::builder()
|
||||||
.method("PUT")
|
.method("PUT")
|
||||||
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
||||||
@ -101,7 +101,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
#[cfg(feature = "compat")]
|
#[cfg(feature = "compat")]
|
||||||
{
|
{
|
||||||
let req = IncomingRequest::try_from_http_request(
|
let req = Request::try_from_http_request(
|
||||||
http::Request::builder()
|
http::Request::builder()
|
||||||
.method("PUT")
|
.method("PUT")
|
||||||
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, UserId,
|
metadata, OwnedUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,14 +24,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_display_name` endpoint.
|
/// Request type for the `set_display_name` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The user whose display name will be set.
|
/// The user whose display name will be set.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: &'a UserId,
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
/// The new display name for the user.
|
/// The new display name for the user.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub displayname: Option<&'a str>,
|
pub displayname: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `set_display_name` endpoint.
|
/// Response type for the `set_display_name` endpoint.
|
||||||
@ -39,9 +39,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given user ID and display name.
|
/// Creates a new `Request` with the given user ID and display name.
|
||||||
pub fn new(user_id: &'a UserId, displayname: Option<&'a str>) -> Self {
|
pub fn new(user_id: OwnedUserId, displayname: Option<String>) -> Self {
|
||||||
Self { user_id, displayname }
|
Self { user_id, displayname }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `delete_pushrule` endpoint.
|
/// Request type for the `delete_pushrule` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The scope to delete from.
|
/// The scope to delete from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
@ -37,7 +37,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The identifier for the rule.
|
/// The identifier for the rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub rule_id: &'a str,
|
pub rule_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `delete_pushrule` endpoint.
|
/// Response type for the `delete_pushrule` endpoint.
|
||||||
@ -45,9 +45,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, kind and rule ID.
|
/// Creates a new `Request` with the given scope, kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: &'a str) -> Self {
|
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { scope, kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ pub mod v3 {
|
|||||||
/// Request type for the `get_notifications` endpoint.
|
/// Request type for the `get_notifications` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// Pagination token given to retrieve the next set of events.
|
/// Pagination token given to retrieve the next set of events.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub from: Option<&'a str>,
|
pub from: Option<String>,
|
||||||
|
|
||||||
/// Limit on the number of events to return in this request.
|
/// Limit on the number of events to return in this request.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
@ -48,7 +48,7 @@ pub mod v3 {
|
|||||||
/// tweak set.
|
/// tweak set.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub only: Option<&'a str>,
|
pub only: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_notifications` endpoint.
|
/// Response type for the `get_notifications` endpoint.
|
||||||
@ -65,7 +65,7 @@ pub mod v3 {
|
|||||||
pub notifications: Vec<Notification>,
|
pub notifications: Vec<Notification>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates an empty `Request`.
|
/// Creates an empty `Request`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_pushrule` endpoint.
|
/// Request type for the `get_pushrule` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The scope to fetch rules from.
|
/// The scope to fetch rules from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
@ -37,7 +37,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The identifier for the rule.
|
/// The identifier for the rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub rule_id: &'a str,
|
pub rule_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_pushrule` endpoint.
|
/// Response type for the `get_pushrule` endpoint.
|
||||||
@ -48,9 +48,9 @@ pub mod v3 {
|
|||||||
pub rule: PushRule,
|
pub rule: PushRule,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: &'a str) -> Self {
|
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { scope, kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_pushrule_actions` endpoint.
|
/// Request type for the `get_pushrule_actions` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
/// The scope to fetch a rule from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
@ -38,7 +38,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The identifier for the rule.
|
/// The identifier for the rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub rule_id: &'a str,
|
pub rule_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_pushrule_actions` endpoint.
|
/// Response type for the `get_pushrule_actions` endpoint.
|
||||||
@ -48,9 +48,9 @@ pub mod v3 {
|
|||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, kind and rule ID.
|
/// Creates a new `Request` with the given scope, kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: &'a str) -> Self {
|
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { scope, kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `get_pushrule_enabled` endpoint.
|
/// Request type for the `get_pushrule_enabled` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
/// The scope to fetch a rule from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
@ -37,7 +37,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The identifier for the rule.
|
/// The identifier for the rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub rule_id: &'a str,
|
pub rule_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_pushrule_enabled` endpoint.
|
/// Response type for the `get_pushrule_enabled` endpoint.
|
||||||
@ -47,9 +47,9 @@ pub mod v3 {
|
|||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: &'a str) -> Self {
|
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { scope, kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ pub mod v3 {
|
|||||||
api::{response, Metadata},
|
api::{response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
push::{Action, NewPushRule, PushCondition},
|
push::{Action, NewPushRule, PushCondition},
|
||||||
serde::Incoming,
|
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -28,10 +27,9 @@ pub mod v3 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `set_pushrule` endpoint.
|
/// Request type for the `set_pushrule` endpoint.
|
||||||
#[derive(Clone, Debug, Incoming)]
|
#[derive(Clone, Debug)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(!Deserialize)]
|
pub struct Request {
|
||||||
pub struct Request<'a> {
|
|
||||||
/// The scope to set the rule in.
|
/// The scope to set the rule in.
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
|
|
||||||
@ -40,11 +38,11 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Use 'before' with a rule_id as its value to make the new rule the next-most important
|
/// Use 'before' with a rule_id as its value to make the new rule the next-most important
|
||||||
/// rule with respect to the given user defined rule.
|
/// rule with respect to the given user defined rule.
|
||||||
pub before: Option<&'a str>,
|
pub before: Option<String>,
|
||||||
|
|
||||||
/// This makes the new rule the next-less important rule relative to the given user defined
|
/// This makes the new rule the next-less important rule relative to the given user defined
|
||||||
/// rule.
|
/// rule.
|
||||||
pub after: Option<&'a str>,
|
pub after: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `set_pushrule` endpoint.
|
/// Response type for the `set_pushrule` endpoint.
|
||||||
@ -52,7 +50,7 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope and rule.
|
/// Creates a new `Request` with the given scope and rule.
|
||||||
pub fn new(scope: RuleScope, rule: NewPushRule) -> Self {
|
pub fn new(scope: RuleScope, rule: NewPushRule) -> Self {
|
||||||
Self { scope, rule, before: None, after: None }
|
Self { scope, rule, before: None, after: None }
|
||||||
@ -67,7 +65,7 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl<'a> ruma_common::api::OutgoingRequest for Request<'a> {
|
impl ruma_common::api::OutgoingRequest for Request {
|
||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type IncomingResponse = Response;
|
type IncomingResponse = Response;
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
impl ruma_common::api::IncomingRequest for IncomingRequest {
|
impl ruma_common::api::IncomingRequest for Request {
|
||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type OutgoingResponse = Response;
|
type OutgoingResponse = Response;
|
||||||
|
|
||||||
@ -196,12 +194,12 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
struct RequestQuery<'a> {
|
struct RequestQuery {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
before: Option<&'a str>,
|
before: Option<String>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
after: Option<&'a str>,
|
after: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
@ -28,7 +28,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_pushrule_actions` endpoint.
|
/// Request type for the `set_pushrule_actions` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
/// The scope to fetch a rule from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
@ -39,7 +39,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The identifier for the rule.
|
/// The identifier for the rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub rule_id: &'a str,
|
pub rule_id: String,
|
||||||
|
|
||||||
/// The actions to perform for this rule
|
/// The actions to perform for this rule
|
||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
@ -50,12 +50,12 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and actions.
|
/// Creates a new `Request` with the given scope, rule kind, rule ID and actions.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
scope: RuleScope,
|
scope: RuleScope,
|
||||||
kind: RuleKind,
|
kind: RuleKind,
|
||||||
rule_id: &'a str,
|
rule_id: String,
|
||||||
actions: Vec<Action>,
|
actions: Vec<Action>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { scope, kind, rule_id, actions }
|
Self { scope, kind, rule_id, actions }
|
||||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_pushrule_enabled` endpoint.
|
/// Request type for the `set_pushrule_enabled` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
/// The scope to fetch a rule from.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub scope: RuleScope,
|
pub scope: RuleScope,
|
||||||
@ -37,7 +37,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The identifier for the rule.
|
/// The identifier for the rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub rule_id: &'a str,
|
pub rule_id: String,
|
||||||
|
|
||||||
/// Whether the push rule is enabled or not.
|
/// Whether the push rule is enabled or not.
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
@ -48,19 +48,19 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and enabled flag.
|
/// Creates a new `Request` with the given scope, rule kind, rule ID and enabled flag.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: &'a str, enabled: bool) -> Self {
|
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String, enabled: bool) -> Self {
|
||||||
Self { scope, kind, rule_id, enabled }
|
Self { scope, kind, rule_id, enabled }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` to enable the given rule.
|
/// Creates a new `Request` to enable the given rule.
|
||||||
pub fn enable(scope: RuleScope, kind: RuleKind, rule_id: &'a str) -> Self {
|
pub fn enable(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self::new(scope, kind, rule_id, true)
|
Self::new(scope, kind, rule_id, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` to disable the given rule.
|
/// Creates a new `Request` to disable the given rule.
|
||||||
pub fn disable(scope: RuleScope, kind: RuleKind, rule_id: &'a str) -> Self {
|
pub fn disable(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self::new(scope, kind, rule_id, false)
|
Self::new(scope, kind, rule_id, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, EventId, RoomId,
|
metadata, OwnedEventId, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -29,10 +29,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `set_read_marker` endpoint.
|
/// Request type for the `set_read_marker` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room ID to set the read marker in for the user.
|
/// The room ID to set the read marker in for the user.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The event ID the fully-read marker should be located at.
|
/// The event ID the fully-read marker should be located at.
|
||||||
///
|
///
|
||||||
@ -44,7 +44,7 @@ pub mod v3 {
|
|||||||
/// [`create_receipt`]: crate::receipt::create_receipt
|
/// [`create_receipt`]: crate::receipt::create_receipt
|
||||||
/// [`ReceiptType::FullyRead`]: crate::receipt::create_receipt::v3::ReceiptType::FullyRead
|
/// [`ReceiptType::FullyRead`]: crate::receipt::create_receipt::v3::ReceiptType::FullyRead
|
||||||
#[serde(rename = "m.fully_read", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "m.fully_read", skip_serializing_if = "Option::is_none")]
|
||||||
pub fully_read: Option<&'a EventId>,
|
pub fully_read: Option<OwnedEventId>,
|
||||||
|
|
||||||
/// The event ID to set the public read receipt location at.
|
/// The event ID to set the public read receipt location at.
|
||||||
///
|
///
|
||||||
@ -54,7 +54,7 @@ pub mod v3 {
|
|||||||
/// [`create_receipt`]: crate::receipt::create_receipt
|
/// [`create_receipt`]: crate::receipt::create_receipt
|
||||||
/// [`ReceiptType::Read`]: crate::receipt::create_receipt::v3::ReceiptType::Read
|
/// [`ReceiptType::Read`]: crate::receipt::create_receipt::v3::ReceiptType::Read
|
||||||
#[serde(rename = "m.read", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "m.read", skip_serializing_if = "Option::is_none")]
|
||||||
pub read_receipt: Option<&'a EventId>,
|
pub read_receipt: Option<OwnedEventId>,
|
||||||
|
|
||||||
/// The event ID to set the private read receipt location at.
|
/// The event ID to set the private read receipt location at.
|
||||||
///
|
///
|
||||||
@ -64,7 +64,7 @@ pub mod v3 {
|
|||||||
/// [`create_receipt`]: crate::receipt::create_receipt
|
/// [`create_receipt`]: crate::receipt::create_receipt
|
||||||
/// [`ReceiptType::ReadPrivate`]: crate::receipt::create_receipt::v3::ReceiptType::ReadPrivate
|
/// [`ReceiptType::ReadPrivate`]: crate::receipt::create_receipt::v3::ReceiptType::ReadPrivate
|
||||||
#[serde(rename = "m.read.private", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "m.read.private", skip_serializing_if = "Option::is_none")]
|
||||||
pub private_read_receipt: Option<&'a EventId>,
|
pub private_read_receipt: Option<OwnedEventId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `set_read_marker` endpoint.
|
/// Response type for the `set_read_marker` endpoint.
|
||||||
@ -72,9 +72,9 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID.
|
/// Creates a new `Request` with the given room ID.
|
||||||
pub fn new(room_id: &'a RoomId) -> Self {
|
pub fn new(room_id: OwnedRoomId) -> Self {
|
||||||
Self { room_id, fully_read: None, read_receipt: None, private_read_receipt: None }
|
Self { room_id, fully_read: None, read_receipt: None, private_read_receipt: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
|||||||
events::receipt::ReceiptThread,
|
events::receipt::ReceiptThread,
|
||||||
metadata,
|
metadata,
|
||||||
serde::{OrdAsRefStr, PartialEqAsRefStr, PartialOrdAsRefStr, StringEnum},
|
serde::{OrdAsRefStr, PartialEqAsRefStr, PartialOrdAsRefStr, StringEnum},
|
||||||
EventId, RoomId,
|
OwnedEventId, OwnedRoomId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::PrivOwnedStr;
|
use crate::PrivOwnedStr;
|
||||||
@ -29,10 +29,10 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `create_receipt` endpoint.
|
/// Request type for the `create_receipt` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The room in which to send the event.
|
/// The room in which to send the event.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The type of receipt to send.
|
/// The type of receipt to send.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -40,7 +40,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// The event ID to acknowledge up to.
|
/// The event ID to acknowledge up to.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: &'a EventId,
|
pub event_id: OwnedEventId,
|
||||||
|
|
||||||
/// The thread this receipt applies to.
|
/// The thread this receipt applies to.
|
||||||
///
|
///
|
||||||
@ -61,9 +61,13 @@ pub mod v3 {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID, receipt type and event ID.
|
/// Creates a new `Request` with the given room ID, receipt type and event ID.
|
||||||
pub fn new(room_id: &'a RoomId, receipt_type: ReceiptType, event_id: &'a EventId) -> Self {
|
pub fn new(
|
||||||
|
room_id: OwnedRoomId,
|
||||||
|
receipt_type: ReceiptType,
|
||||||
|
event_id: OwnedEventId,
|
||||||
|
) -> Self {
|
||||||
Self { room_id, receipt_type, event_id, thread: ReceiptThread::default() }
|
Self { room_id, receipt_type, event_id, thread: ReceiptThread::default() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
|||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, EventId, OwnedEventId, RoomId, TransactionId,
|
metadata, OwnedEventId, OwnedRoomId, OwnedTransactionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
@ -24,14 +24,14 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Request type for the `redact_event` endpoint.
|
/// Request type for the `redact_event` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request<'a> {
|
pub struct Request {
|
||||||
/// The ID of the room of the event to redact.
|
/// The ID of the room of the event to redact.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: &'a RoomId,
|
pub room_id: OwnedRoomId,
|
||||||
|
|
||||||
/// The ID of the event to redact.
|
/// The ID of the event to redact.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: &'a EventId,
|
pub event_id: OwnedEventId,
|
||||||
|
|
||||||
/// The transaction ID for this event.
|
/// The transaction ID for this event.
|
||||||
///
|
///
|
||||||
@ -43,11 +43,11 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// [access token is refreshed]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
|
/// [access token is refreshed]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub txn_id: &'a TransactionId,
|
pub txn_id: OwnedTransactionId,
|
||||||
|
|
||||||
/// The reason for the redaction.
|
/// The reason for the redaction.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub reason: Option<&'a str>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `redact_event` endpoint.
|
/// Response type for the `redact_event` endpoint.
|
||||||
@ -57,9 +57,13 @@ pub mod v3 {
|
|||||||
pub event_id: OwnedEventId,
|
pub event_id: OwnedEventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Request<'a> {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID, event ID and transaction ID.
|
/// Creates a new `Request` with the given room ID, event ID and transaction ID.
|
||||||
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, txn_id: &'a TransactionId) -> Self {
|
pub fn new(
|
||||||
|
room_id: OwnedRoomId,
|
||||||
|
event_id: OwnedEventId,
|
||||||
|
txn_id: OwnedTransactionId,
|
||||||
|
) -> Self {
|
||||||
Self { room_id, event_id, txn_id, reason: None }
|
Self { room_id, event_id, txn_id, reason: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user