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
|
||||
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
|
||||
|
||||
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,
|
||||
metadata,
|
||||
serde::Raw,
|
||||
OwnedTransactionId, TransactionId,
|
||||
OwnedTransactionId,
|
||||
};
|
||||
#[cfg(feature = "unstable-msc2409")]
|
||||
use ruma_common::{
|
||||
@ -48,15 +48,15 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `push_events` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The transaction ID for this set of events.
|
||||
///
|
||||
/// Homeservers generate these IDs and they are used to ensure idempotency of results.
|
||||
#[ruma_api(path)]
|
||||
pub txn_id: &'a TransactionId,
|
||||
pub txn_id: OwnedTransactionId,
|
||||
|
||||
/// A list of events.
|
||||
pub events: &'a [Raw<AnyTimelineEvent>],
|
||||
pub events: Vec<Raw<AnyTimelineEvent>>,
|
||||
|
||||
/// Information on E2E device updates.
|
||||
#[cfg(feature = "unstable-msc3202")]
|
||||
@ -96,7 +96,7 @@ pub mod v1 {
|
||||
skip_serializing_if = "<[_]>::is_empty",
|
||||
rename = "de.sorunome.msc2409.ephemeral"
|
||||
)]
|
||||
pub ephemeral: &'a [Edu],
|
||||
pub ephemeral: Vec<Edu>,
|
||||
|
||||
/// A list of to-device messages.
|
||||
#[cfg(feature = "unstable-msc2409")]
|
||||
@ -105,7 +105,7 @@ pub mod v1 {
|
||||
skip_serializing_if = "<[_]>::is_empty",
|
||||
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.
|
||||
@ -113,33 +113,10 @@ pub mod v1 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given transaction ID and list of events.
|
||||
pub fn new(txn_id: &'a TransactionId, events: &'a [Raw<AnyTimelineEvent>]) -> Self {
|
||||
Self {
|
||||
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 {
|
||||
impl Request {
|
||||
/// Creates an `Request` with the given transaction ID and list of events.
|
||||
pub fn new(txn_id: OwnedTransactionId, events: Vec<Raw<AnyTimelineEvent>>) -> Request {
|
||||
Request {
|
||||
txn_id,
|
||||
events,
|
||||
#[cfg(feature = "unstable-msc3202")]
|
||||
@ -393,7 +370,7 @@ pub mod v1 {
|
||||
.unwrap();
|
||||
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>>(
|
||||
"https://homeserver.tld",
|
||||
SendAccessToken::IfRequired("auth_tok"),
|
||||
|
@ -9,7 +9,7 @@ pub mod v1 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomAliasId,
|
||||
metadata, OwnedRoomAliasId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -23,10 +23,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `query_room_alias` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room alias being queried.
|
||||
#[ruma_api(path)]
|
||||
pub room_alias: &'a RoomAliasId,
|
||||
pub room_alias: OwnedRoomAliasId,
|
||||
}
|
||||
|
||||
/// Response type for the `query_room_alias` endpoint.
|
||||
@ -34,9 +34,9 @@ pub mod v1 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v1 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, UserId,
|
||||
metadata, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -23,10 +23,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `query_user_id` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user ID being queried.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `query_user_id` endpoint.
|
||||
@ -34,9 +34,9 @@ pub mod v1 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `get_location_for_protocol` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The protocol used to communicate to the third party network.
|
||||
#[ruma_api(path)]
|
||||
pub protocol: &'a str,
|
||||
pub protocol: String,
|
||||
|
||||
/// 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).
|
||||
@ -45,9 +45,9 @@ pub mod v1 {
|
||||
pub locations: Vec<Location>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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() }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub mod v1 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
thirdparty::Location,
|
||||
RoomAliasId,
|
||||
OwnedRoomAliasId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -25,10 +25,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `get_location_for_room_alias` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The Matrix room alias to look up.
|
||||
#[ruma_api(query)]
|
||||
pub alias: &'a RoomAliasId,
|
||||
pub alias: OwnedRoomAliasId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_location_for_room_alias` endpoint.
|
||||
@ -39,9 +39,9 @@ pub mod v1 {
|
||||
pub locations: Vec<Location>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `get_protocol` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The name of the protocol.
|
||||
#[ruma_api(path)]
|
||||
pub protocol: &'a str,
|
||||
pub protocol: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_protocol` endpoint.
|
||||
@ -38,9 +38,9 @@ pub mod v1 {
|
||||
pub protocol: Protocol,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given protocol name.
|
||||
pub fn new(protocol: &'a str) -> Self {
|
||||
pub fn new(protocol: String) -> Self {
|
||||
Self { protocol }
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `get_user_for_protocol` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The protocol used to communicate to the third party network.
|
||||
#[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.
|
||||
// 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>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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() }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub mod v1 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
thirdparty::User,
|
||||
UserId,
|
||||
OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -25,10 +25,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `get_user_for_user_id` endpoint.
|
||||
#[request]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The Matrix User ID to look up.
|
||||
#[ruma_api(query)]
|
||||
pub userid: &'a UserId,
|
||||
pub userid: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_user_for_user_id` endpoint.
|
||||
@ -39,9 +39,9 @@ pub mod v1 {
|
||||
pub users: Vec<User>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given user id.
|
||||
pub fn new(userid: &'a UserId) -> Self {
|
||||
pub fn new(userid: OwnedUserId) -> Self {
|
||||
Self { userid }
|
||||
}
|
||||
}
|
||||
|
@ -19,26 +19,26 @@ pub mod request_registration_token_via_msisdn;
|
||||
pub mod unbind_3pid;
|
||||
pub mod whoami;
|
||||
|
||||
use ruma_common::serde::{Incoming, StringEnum};
|
||||
use serde::Serialize;
|
||||
use ruma_common::serde::StringEnum;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
/// 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)]
|
||||
pub struct IdentityServerInfo<'a> {
|
||||
pub struct IdentityServerInfo {
|
||||
/// 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.
|
||||
pub id_server: &'a str,
|
||||
pub id_server: String,
|
||||
|
||||
/// 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.
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
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! {
|
||||
method: POST,
|
||||
@ -26,16 +26,16 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `add_3pid` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Additional information for the User-Interactive Authentication API.
|
||||
#[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.
|
||||
pub client_secret: &'a ClientSecret,
|
||||
pub client_secret: OwnedClientSecret,
|
||||
|
||||
/// The session identifier given by the identity server.
|
||||
pub sid: &'a SessionId,
|
||||
pub sid: OwnedSessionId,
|
||||
}
|
||||
|
||||
/// Response type for the `add_3pid` endpoint.
|
||||
@ -43,9 +43,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, SessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||
use crate::account::IdentityServerInfo;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -26,17 +26,17 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `bind_3pid` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// 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
|
||||
/// appended colon and port number if the port is not the default.
|
||||
#[serde(flatten)]
|
||||
pub identity_server_info: IdentityServerInfo<'a>,
|
||||
pub identity_server_info: IdentityServerInfo,
|
||||
|
||||
/// The session identifier given by the identity server.
|
||||
pub sid: &'a SessionId,
|
||||
pub sid: OwnedSessionId,
|
||||
}
|
||||
|
||||
/// Response type for the `bind_3pid` endpoint.
|
||||
@ -44,13 +44,13 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given client secret, identity server information and
|
||||
/// session identifier.
|
||||
pub fn new(
|
||||
client_secret: &'a ClientSecret,
|
||||
identity_server_info: IdentityServerInfo<'a>,
|
||||
sid: &'a SessionId,
|
||||
client_secret: OwnedClientSecret,
|
||||
identity_server_info: IdentityServerInfo,
|
||||
sid: OwnedSessionId,
|
||||
) -> Self {
|
||||
Self { client_secret, identity_server_info, sid }
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
metadata,
|
||||
};
|
||||
|
||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
||||
use crate::uiaa::{AuthData, UiaaResponse};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -26,9 +26,9 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `change_password` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// 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
|
||||
/// request succeeds.
|
||||
@ -45,7 +45,7 @@ pub mod v3 {
|
||||
|
||||
/// Additional authentication information for the user-interactive authentication API.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub auth: Option<AuthData<'a>>,
|
||||
pub auth: Option<AuthData>,
|
||||
}
|
||||
|
||||
/// Response type for the `change_password` endpoint.
|
||||
@ -53,9 +53,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ pub mod v1 {
|
||||
|
||||
/// Request type for the `check_registration_token_validity` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The registration token to check the validity of.
|
||||
#[ruma_api(query)]
|
||||
pub registration_token: &'a str,
|
||||
pub registration_token: String,
|
||||
}
|
||||
|
||||
/// Response type for the `check_registration_token_validity` endpoint.
|
||||
@ -37,9 +37,9 @@ pub mod v1 {
|
||||
pub valid: bool,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
||||
|
||||
use crate::{
|
||||
account::ThirdPartyIdRemovalStatus,
|
||||
uiaa::{AuthData, IncomingAuthData, UiaaResponse},
|
||||
uiaa::{AuthData, UiaaResponse},
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -30,15 +30,15 @@ pub mod v3 {
|
||||
/// Request type for the `deactivate` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Additional authentication information for the user-interactive authentication API.
|
||||
#[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
|
||||
/// identifier.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub id_server: Option<&'a str>,
|
||||
pub id_server: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `deactivate` endpoint.
|
||||
@ -48,7 +48,7 @@ pub mod v3 {
|
||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||
}
|
||||
|
||||
impl Request<'_> {
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
|
@ -27,16 +27,16 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_3pid` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Identity server to delete from.
|
||||
#[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.
|
||||
pub medium: Medium,
|
||||
|
||||
/// Third-party address being removed.
|
||||
pub address: &'a str,
|
||||
pub address: String,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_3pid` endpoint.
|
||||
@ -46,9 +46,9 @@ pub mod v3 {
|
||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_username_availability` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The username to check the availability of.
|
||||
#[ruma_api(query)]
|
||||
pub username: &'a str,
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_username_availability` endpoint.
|
||||
@ -38,9 +38,9 @@ pub mod v3 {
|
||||
pub available: bool,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given username.
|
||||
pub fn new(username: &'a str) -> Self {
|
||||
pub fn new(username: String) -> Self {
|
||||
Self { username }
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, DeviceId, OwnedDeviceId, OwnedUserId,
|
||||
metadata, OwnedDeviceId, OwnedUserId,
|
||||
};
|
||||
|
||||
use super::{LoginType, RegistrationKind};
|
||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
||||
use crate::uiaa::{AuthData, UiaaResponse};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -32,32 +32,32 @@ pub mod v3 {
|
||||
/// Request type for the `register` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The desired password for the account.
|
||||
///
|
||||
/// 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.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub password: Option<&'a str>,
|
||||
pub password: Option<String>,
|
||||
|
||||
/// Localpart of the desired Matrix ID.
|
||||
///
|
||||
/// If omitted, the homeserver MUST generate a Matrix ID local part.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub username: Option<&'a str>,
|
||||
pub username: Option<String>,
|
||||
|
||||
/// ID of the client device.
|
||||
///
|
||||
/// 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.
|
||||
#[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.
|
||||
///
|
||||
/// Ignored if `device_id` corresponds to a known device.
|
||||
#[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.
|
||||
///
|
||||
@ -66,7 +66,7 @@ pub mod v3 {
|
||||
/// It should be left empty, or omitted, unless an earlier call returned an response
|
||||
/// with status code 401.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub auth: Option<AuthData<'a>>,
|
||||
pub auth: Option<AuthData>,
|
||||
|
||||
/// 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
|
||||
#[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].
|
||||
///
|
||||
@ -147,7 +147,7 @@ pub mod v3 {
|
||||
pub expires_in: Option<Duration>,
|
||||
}
|
||||
|
||||
impl Request<'_> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with all parameters defaulted.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, OwnedSessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||
use crate::account::IdentityServerInfo;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -27,25 +27,25 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_3pid_management_token_via_email` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Client-generated secret string used to protect this session.
|
||||
pub client_secret: &'a ClientSecret,
|
||||
pub client_secret: OwnedClientSecret,
|
||||
|
||||
/// The email address.
|
||||
pub email: &'a str,
|
||||
pub email: String,
|
||||
|
||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||
pub send_attempt: UInt,
|
||||
|
||||
/// Return URL for identity server to redirect the client back to.
|
||||
#[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.
|
||||
///
|
||||
/// Deprecated since r0.6.0.
|
||||
#[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.
|
||||
@ -68,9 +68,9 @@ pub mod v3 {
|
||||
pub submit_url: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, OwnedSessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||
use crate::account::IdentityServerInfo;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -27,28 +27,28 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_3pid_management_token_via_msisdn` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// 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.
|
||||
pub country: &'a str,
|
||||
pub country: String,
|
||||
|
||||
/// 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.
|
||||
pub send_attempt: UInt,
|
||||
|
||||
/// Return URL for identity server to redirect the client back to.
|
||||
#[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.
|
||||
///
|
||||
/// Deprecated since r0.6.0.
|
||||
#[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.
|
||||
@ -71,13 +71,13 @@ pub mod v3 {
|
||||
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
|
||||
/// send-attempt counter.
|
||||
pub fn new(
|
||||
client_secret: &'a ClientSecret,
|
||||
country: &'a str,
|
||||
phone_number: &'a str,
|
||||
client_secret: OwnedClientSecret,
|
||||
country: String,
|
||||
phone_number: String,
|
||||
send_attempt: UInt,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
authentication::TokenType,
|
||||
metadata, OwnedServerName, UserId,
|
||||
metadata, OwnedServerName, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -27,10 +27,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_openid_token` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// User ID of authenticated user.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `request_openid_token` endpoint.
|
||||
@ -50,9 +50,9 @@ pub mod v3 {
|
||||
pub expires_in: Duration,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, OwnedSessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||
use crate::account::IdentityServerInfo;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -27,25 +27,25 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_password_change_token_via_email` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Client-generated secret string used to protect this session.
|
||||
pub client_secret: &'a ClientSecret,
|
||||
pub client_secret: OwnedClientSecret,
|
||||
|
||||
/// The email address.
|
||||
pub email: &'a str,
|
||||
pub email: String,
|
||||
|
||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||
pub send_attempt: UInt,
|
||||
|
||||
/// Return URL for identity server to redirect the client back to.
|
||||
#[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.
|
||||
///
|
||||
/// Deprecated since r0.6.0.
|
||||
#[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.
|
||||
@ -68,10 +68,10 @@ pub mod v3 {
|
||||
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
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, OwnedSessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -25,22 +25,22 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_password_change_token_via_msisdn` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// 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.
|
||||
pub country: &'a str,
|
||||
pub country: String,
|
||||
|
||||
/// 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.
|
||||
pub send_attempt: UInt,
|
||||
|
||||
/// Return URL for identity server to redirect the client back to.
|
||||
#[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.
|
||||
@ -63,13 +63,13 @@ pub mod v3 {
|
||||
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
|
||||
/// send-attempt counter.
|
||||
pub fn new(
|
||||
client_secret: &'a ClientSecret,
|
||||
country: &'a str,
|
||||
phone_number: &'a str,
|
||||
client_secret: OwnedClientSecret,
|
||||
country: String,
|
||||
phone_number: String,
|
||||
send_attempt: UInt,
|
||||
) -> Self {
|
||||
Self { client_secret, country, phone_number, send_attempt, next_link: None }
|
||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, OwnedSessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||
use crate::account::IdentityServerInfo;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -27,25 +27,25 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_registration_token_via_email` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Client-generated secret string used to protect this session.
|
||||
pub client_secret: &'a ClientSecret,
|
||||
pub client_secret: OwnedClientSecret,
|
||||
|
||||
/// The email address.
|
||||
pub email: &'a str,
|
||||
pub email: String,
|
||||
|
||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||
pub send_attempt: UInt,
|
||||
|
||||
/// Return URL for identity server to redirect the client back to.
|
||||
#[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.
|
||||
///
|
||||
/// Deprecated since r0.6.0.
|
||||
#[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.
|
||||
@ -68,10 +68,10 @@ pub mod v3 {
|
||||
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
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, ClientSecret, OwnedSessionId,
|
||||
metadata, OwnedClientSecret, OwnedSessionId,
|
||||
};
|
||||
|
||||
use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||
use crate::account::IdentityServerInfo;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -27,28 +27,28 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `request_registration_token_via_msisdn` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// 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.
|
||||
pub country: &'a str,
|
||||
pub country: String,
|
||||
|
||||
/// 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.
|
||||
pub send_attempt: UInt,
|
||||
|
||||
/// Return URL for identity server to redirect the client back to.
|
||||
#[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.
|
||||
///
|
||||
/// Deprecated since r0.6.0.
|
||||
#[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.
|
||||
@ -71,13 +71,13 @@ pub mod v3 {
|
||||
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
|
||||
/// send-attempt counter.
|
||||
pub fn new(
|
||||
client_secret: &'a ClientSecret,
|
||||
country: &'a str,
|
||||
phone_number: &'a str,
|
||||
client_secret: OwnedClientSecret,
|
||||
country: String,
|
||||
phone_number: String,
|
||||
send_attempt: UInt,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -27,16 +27,16 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `unbind_3pid` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Identity server to unbind from.
|
||||
#[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.
|
||||
pub medium: Medium,
|
||||
|
||||
/// Third-party address being removed.
|
||||
pub address: &'a str,
|
||||
pub address: String,
|
||||
}
|
||||
|
||||
/// Response type for the `unbind_3pid` endpoint.
|
||||
@ -46,9 +46,9 @@ pub mod v3 {
|
||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomAliasId, RoomId,
|
||||
metadata, OwnedRoomAliasId, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,13 +24,13 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `create_alias` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room alias to set.
|
||||
#[ruma_api(path)]
|
||||
pub room_alias: &'a RoomAliasId,
|
||||
pub room_alias: OwnedRoomAliasId,
|
||||
|
||||
/// The room ID to set.
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
/// Response type for the `create_alias` endpoint.
|
||||
@ -38,9 +38,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomAliasId,
|
||||
metadata, OwnedRoomAliasId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_alias` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room alias to remove.
|
||||
#[ruma_api(path)]
|
||||
pub room_alias: &'a RoomAliasId,
|
||||
pub room_alias: OwnedRoomAliasId,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_alias` endpoint.
|
||||
@ -35,9 +35,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedRoomId, OwnedServerName, RoomAliasId,
|
||||
metadata, OwnedRoomAliasId, OwnedRoomId, OwnedServerName,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_alias` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room alias.
|
||||
#[ruma_api(path)]
|
||||
pub room_alias: &'a RoomAliasId,
|
||||
pub room_alias: OwnedRoomAliasId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_alias` endpoint.
|
||||
@ -40,9 +40,9 @@ pub mod v3 {
|
||||
pub servers: Vec<OwnedServerName>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::room::Visibility;
|
||||
@ -26,14 +26,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_room_visibility` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The protocol (network) ID to update the room list for.
|
||||
#[ruma_api(path)]
|
||||
pub network_id: &'a str,
|
||||
pub network_id: String,
|
||||
|
||||
/// The room ID to add to the directory.
|
||||
#[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).
|
||||
pub visibility: Visibility,
|
||||
@ -44,9 +44,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `add_backup_keys` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to add keys to.
|
||||
///
|
||||
/// Must be the current backup.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// A map of room IDs to session IDs to key data to store.
|
||||
pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
|
||||
@ -53,9 +53,9 @@ pub mod v3 {
|
||||
pub count: UInt,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::backup::KeyBackupData;
|
||||
@ -32,16 +32,16 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `add_backup_keys_for_room` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to add keys to.
|
||||
///
|
||||
/// Must be the current backup.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The ID of the room to add keys to.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// A map of session IDs to key data to store.
|
||||
pub sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
||||
@ -60,11 +60,11 @@ pub mod v3 {
|
||||
pub count: UInt,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given version, room_id and sessions.
|
||||
pub fn new(
|
||||
version: &'a str,
|
||||
room_id: &'a RoomId,
|
||||
version: String,
|
||||
room_id: OwnedRoomId,
|
||||
sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
||||
) -> Self {
|
||||
Self { version, room_id, sessions }
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::backup::KeyBackupData;
|
||||
@ -30,20 +30,20 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `add_backup_keys_for_session` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to add keys to.
|
||||
///
|
||||
/// Must be the current backup.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The ID of the room to add keys to.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The ID of the megolm session to add keys to.
|
||||
#[ruma_api(path)]
|
||||
pub session_id: &'a str,
|
||||
pub session_id: String,
|
||||
|
||||
/// The key information to store.
|
||||
#[ruma_api(body)]
|
||||
@ -63,12 +63,12 @@ pub mod v3 {
|
||||
pub count: UInt,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given version, room_id, session_id and session_data.
|
||||
pub fn new(
|
||||
version: &'a str,
|
||||
room_id: &'a RoomId,
|
||||
session_id: &'a str,
|
||||
version: String,
|
||||
room_id: OwnedRoomId,
|
||||
session_id: String,
|
||||
session_data: Raw<KeyBackupData>,
|
||||
) -> Self {
|
||||
Self { version, room_id, session_id, session_data }
|
||||
|
@ -28,10 +28,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_backup_keys` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version from which to delete keys.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_backup_keys` endpoint.
|
||||
@ -47,9 +47,9 @@ pub mod v3 {
|
||||
pub count: UInt,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given version.
|
||||
pub fn new(version: &'a str) -> Self {
|
||||
pub fn new(version: String) -> Self {
|
||||
Self { version }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -26,14 +26,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_backup_keys_for_room` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version from which to delete keys.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The ID of the room to delete keys from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_backup_keys_for_room` endpoint.
|
||||
@ -49,10 +49,10 @@ pub mod v3 {
|
||||
pub count: UInt,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -26,18 +26,18 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_backup_keys_for_session` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version from which to delete keys.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The ID of the room to delete keys from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The ID of the megolm session to delete keys from.
|
||||
#[ruma_api(path)]
|
||||
pub session_id: &'a str,
|
||||
pub session_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_backup_keys_for_session` endpoint.
|
||||
@ -53,9 +53,9 @@ pub mod v3 {
|
||||
pub count: UInt,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_backup_version` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to delete.
|
||||
#[ruma_api(path)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_backup_version` endpoint.
|
||||
@ -38,9 +38,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_backup_info` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to retrieve info from.
|
||||
#[ruma_api(path)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_backup_info` endpoint.
|
||||
@ -56,9 +56,9 @@ pub mod v3 {
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given version.
|
||||
pub fn new(version: &'a str) -> Self {
|
||||
pub fn new(version: String) -> Self {
|
||||
Self { version }
|
||||
}
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_backup_keys` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to retrieve keys from.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_backup_keys` endpoint.
|
||||
@ -42,9 +42,9 @@ pub mod v3 {
|
||||
pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given version.
|
||||
pub fn new(version: &'a str) -> Self {
|
||||
pub fn new(version: String) -> Self {
|
||||
Self { version }
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ pub mod v3 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::backup::KeyBackupData;
|
||||
@ -31,14 +31,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_backup_keys_for_room` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to retrieve keys from.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The ID of the room that the requested key is for.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_backup_keys_for_room` endpoint.
|
||||
@ -48,9 +48,9 @@ pub mod v3 {
|
||||
pub sessions: BTreeMap<String, Raw<KeyBackupData>>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::backup::KeyBackupData;
|
||||
@ -29,18 +29,18 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_backup_keys_for_session` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version to retrieve keys from.
|
||||
#[ruma_api(query)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The ID of the room that the requested key is for.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The ID of the megolm session whose key is requested.
|
||||
#[ruma_api(path)]
|
||||
pub session_id: &'a str,
|
||||
pub session_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_backup_keys_for_session` endpoint.
|
||||
@ -51,9 +51,9 @@ pub mod v3 {
|
||||
pub key_data: Raw<KeyBackupData>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `update_backup_version` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The backup version.
|
||||
#[ruma_api(path)]
|
||||
pub version: &'a str,
|
||||
pub version: String,
|
||||
|
||||
/// The algorithm used for storing backups.
|
||||
#[ruma_api(body)]
|
||||
@ -42,9 +42,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
events::AnyGlobalAccountDataEventContent,
|
||||
metadata,
|
||||
serde::Raw,
|
||||
UserId,
|
||||
OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -27,14 +27,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_global_account_data` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// User ID of user for whom to retrieve data.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// Type of data to retrieve.
|
||||
#[ruma_api(path)]
|
||||
pub event_type: &'a str,
|
||||
pub event_type: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_global_account_data` endpoint.
|
||||
@ -47,9 +47,9 @@ pub mod v3 {
|
||||
pub account_data: Raw<AnyGlobalAccountDataEventContent>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
events::AnyRoomAccountDataEventContent,
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId, UserId,
|
||||
OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -27,18 +27,18 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_room_account_data` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// User ID of user for whom to retrieve data.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// Room ID for which to retrieve data.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// Type of data to retrieve.
|
||||
#[ruma_api(path)]
|
||||
pub event_type: &'a str,
|
||||
pub event_type: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_room_account_data` endpoint.
|
||||
@ -51,9 +51,9 @@ pub mod v3 {
|
||||
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.
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ pub mod v3 {
|
||||
},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
UserId,
|
||||
OwnedUserId,
|
||||
};
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The ID of the user to set account_data for.
|
||||
///
|
||||
/// The access token must be authorized to make requests for this user ID.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The event type of the account_data to set.
|
||||
///
|
||||
@ -56,14 +56,14 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given data, event type and user ID.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||
/// `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
|
||||
T: GlobalAccountDataEventContent,
|
||||
{
|
||||
@ -76,7 +76,7 @@ pub mod v3 {
|
||||
|
||||
/// Creates a new `Request` with the given raw data, event type and user ID.
|
||||
pub fn new_raw(
|
||||
user_id: &'a UserId,
|
||||
user_id: OwnedUserId,
|
||||
event_type: GlobalAccountDataEventType,
|
||||
data: Raw<AnyGlobalAccountDataEventContent>,
|
||||
) -> Self {
|
||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
||||
},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId, UserId,
|
||||
OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The ID of the user to set account_data for.
|
||||
///
|
||||
/// The access token must be authorized to make requests for this user ID.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The ID of the room to set account_data on.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The event type of the account_data to set.
|
||||
///
|
||||
@ -59,7 +59,7 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given data, event type, room ID and user ID.
|
||||
///
|
||||
/// # Errors
|
||||
@ -67,9 +67,9 @@ pub mod v3 {
|
||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||
pub fn new<T>(
|
||||
user_id: &'a UserId,
|
||||
room_id: &'a RoomId,
|
||||
data: &'a T,
|
||||
user_id: OwnedUserId,
|
||||
room_id: OwnedRoomId,
|
||||
data: &T,
|
||||
) -> serde_json::Result<Self>
|
||||
where
|
||||
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.
|
||||
pub fn new_raw(
|
||||
user_id: &'a UserId,
|
||||
room_id: &'a RoomId,
|
||||
user_id: OwnedUserId,
|
||||
room_id: OwnedRoomId,
|
||||
event_type: RoomAccountDataEventType,
|
||||
data: Raw<AnyRoomAccountDataEventContent>,
|
||||
) -> Self {
|
||||
|
@ -13,10 +13,10 @@ pub mod v3 {
|
||||
events::{AnyStateEvent, AnyTimelineEvent},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
EventId, RoomId,
|
||||
OwnedEventId, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::filter::{IncomingRoomEventFilter, RoomEventFilter};
|
||||
use crate::filter::RoomEventFilter;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
@ -30,14 +30,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_context` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to get events from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The event to get context around.
|
||||
#[ruma_api(path)]
|
||||
pub event_id: &'a EventId,
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// The maximum number of events to return.
|
||||
///
|
||||
@ -53,7 +53,7 @@ pub mod v3 {
|
||||
default,
|
||||
skip_serializing_if = "RoomEventFilter::is_empty"
|
||||
)]
|
||||
pub filter: RoomEventFilter<'a>,
|
||||
pub filter: RoomEventFilter,
|
||||
}
|
||||
|
||||
/// Response type for the `get_context` endpoint.
|
||||
@ -87,9 +87,9 @@ pub mod v3 {
|
||||
pub state: Vec<Raw<AnyStateEvent>>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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() }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, DeviceId,
|
||||
metadata, OwnedDeviceId,
|
||||
};
|
||||
|
||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
||||
use crate::uiaa::{AuthData, UiaaResponse};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: DELETE,
|
||||
@ -26,14 +26,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_device` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The device to delete.
|
||||
#[ruma_api(path)]
|
||||
pub device_id: &'a DeviceId,
|
||||
pub device_id: OwnedDeviceId,
|
||||
|
||||
/// Additional authentication information for the user-interactive authentication API.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub auth: Option<AuthData<'a>>,
|
||||
pub auth: Option<AuthData>,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_device` endpoint.
|
||||
@ -41,9 +41,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
metadata, OwnedDeviceId,
|
||||
};
|
||||
|
||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
||||
use crate::uiaa::{AuthData, UiaaResponse};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -26,13 +26,13 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_devices` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// List of devices to delete.
|
||||
pub devices: &'a [OwnedDeviceId],
|
||||
pub devices: Vec<OwnedDeviceId>,
|
||||
|
||||
/// Additional authentication information for the user-interactive authentication API.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub auth: Option<AuthData<'a>>,
|
||||
pub auth: Option<AuthData>,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_devices` endpoint.
|
||||
@ -40,9 +40,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, DeviceId,
|
||||
metadata, OwnedDeviceId,
|
||||
};
|
||||
|
||||
use crate::device::Device;
|
||||
@ -26,10 +26,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_device` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The device to retrieve.
|
||||
#[ruma_api(path)]
|
||||
pub device_id: &'a DeviceId,
|
||||
pub device_id: OwnedDeviceId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_device` endpoint.
|
||||
@ -40,9 +40,9 @@ pub mod v3 {
|
||||
pub device: Device,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, DeviceId,
|
||||
metadata, OwnedDeviceId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,16 +24,16 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `update_device` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The device to update.
|
||||
#[ruma_api(path)]
|
||||
pub device_id: &'a DeviceId,
|
||||
pub device_id: OwnedDeviceId,
|
||||
|
||||
/// The new display name for this device.
|
||||
///
|
||||
/// If this is `None`, the display name won't be changed.
|
||||
#[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.
|
||||
@ -41,9 +41,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
directory::PublicRoomsChunk,
|
||||
metadata, ServerName,
|
||||
metadata, OwnedServerName,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -27,7 +27,7 @@ pub mod v3 {
|
||||
/// Request type for the `get_public_rooms` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Limit for the number of results to return.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
@ -36,14 +36,14 @@ pub mod v3 {
|
||||
/// Pagination token from a previous request.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub since: Option<&'a str>,
|
||||
pub since: Option<String>,
|
||||
|
||||
/// The server to fetch the public room lists from.
|
||||
///
|
||||
/// `None` means the server this request is sent to.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub server: Option<&'a ServerName>,
|
||||
pub server: Option<OwnedServerName>,
|
||||
}
|
||||
|
||||
/// Response type for the `get_public_rooms` endpoint.
|
||||
@ -65,7 +65,7 @@ pub mod v3 {
|
||||
pub total_room_count_estimate: Option<UInt>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
@ -93,8 +93,8 @@ pub mod v3 {
|
||||
|
||||
let req = super::Request {
|
||||
limit: Some(uint!(10)),
|
||||
since: Some("hello"),
|
||||
server: Some(server_name!("test.tld")),
|
||||
since: Some("hello".to_owned()),
|
||||
server: Some(server_name!("test.tld").to_owned()),
|
||||
}
|
||||
.try_into_http_request::<Vec<u8>>(
|
||||
"https://homeserver.tld",
|
||||
|
@ -10,8 +10,8 @@ pub mod v3 {
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
directory::{Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork},
|
||||
metadata, ServerName,
|
||||
directory::{Filter, PublicRoomsChunk, RoomNetwork},
|
||||
metadata, OwnedServerName,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -27,13 +27,13 @@ pub mod v3 {
|
||||
/// Request type for the `get_public_rooms_filtered` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The server to fetch the public room lists from.
|
||||
///
|
||||
/// `None` means the server this request is sent to.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub server: Option<&'a ServerName>,
|
||||
pub server: Option<OwnedServerName>,
|
||||
|
||||
/// Limit for the number of results to return.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -41,15 +41,15 @@ pub mod v3 {
|
||||
|
||||
/// Pagination token from a previous request.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub since: Option<&'a str>,
|
||||
pub since: Option<String>,
|
||||
|
||||
/// Filter to apply to the results.
|
||||
#[serde(default, skip_serializing_if = "Filter::is_empty")]
|
||||
pub filter: Filter<'a>,
|
||||
pub filter: Filter,
|
||||
|
||||
/// Network to fetch the public room lists from.
|
||||
#[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.
|
||||
@ -72,7 +72,7 @@ pub mod v3 {
|
||||
pub total_room_count_estimate: Option<UInt>,
|
||||
}
|
||||
|
||||
impl Request<'_> {
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::room::Visibility;
|
||||
@ -26,10 +26,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_room_visibility` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The ID of the room of which to request the visibility.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_room_visibility` endpoint.
|
||||
@ -39,9 +39,9 @@ pub mod v3 {
|
||||
pub visibility: Visibility,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::room::Visibility;
|
||||
@ -26,10 +26,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_room_visibility` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The ID of the room of which to set the visibility.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// New visibility setting for the room.
|
||||
pub visibility: Visibility,
|
||||
@ -40,9 +40,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,8 @@ mod lazy_load;
|
||||
mod url;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
serde::{Incoming, StringEnum},
|
||||
OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use ruma_common::{serde::StringEnum, OwnedRoomId, OwnedUserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
@ -35,24 +32,23 @@ pub enum EventFormat {
|
||||
}
|
||||
|
||||
/// 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)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct RoomEventFilter<'a> {
|
||||
pub struct RoomEventFilter {
|
||||
/// A list of event types to exclude.
|
||||
///
|
||||
/// 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
|
||||
/// sequence of characters.
|
||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||
pub not_types: &'a [String],
|
||||
pub not_types: Vec<String>,
|
||||
|
||||
/// 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
|
||||
/// it is listed in the 'rooms' filter.
|
||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||
pub not_rooms: &'a [OwnedRoomId],
|
||||
pub not_rooms: Vec<OwnedRoomId>,
|
||||
|
||||
/// The maximum number of events to return.
|
||||
#[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.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub rooms: Option<&'a [OwnedRoomId]>,
|
||||
pub rooms: Option<Vec<OwnedRoomId>>,
|
||||
|
||||
/// A list of sender IDs to exclude.
|
||||
///
|
||||
/// 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.
|
||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||
pub not_senders: &'a [OwnedUserId],
|
||||
pub not_senders: Vec<OwnedUserId>,
|
||||
|
||||
/// A list of senders IDs to include.
|
||||
///
|
||||
/// If this list is absent then all senders are included.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub senders: Option<&'a [OwnedUserId]>,
|
||||
pub senders: Option<Vec<OwnedUserId>>,
|
||||
|
||||
/// 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
|
||||
/// to match any sequence of characters.
|
||||
#[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.
|
||||
///
|
||||
@ -108,7 +104,7 @@ pub struct RoomEventFilter<'a> {
|
||||
pub unread_thread_notifications: bool,
|
||||
}
|
||||
|
||||
impl<'a> RoomEventFilter<'a> {
|
||||
impl RoomEventFilter {
|
||||
/// Creates an empty `RoomEventFilter`.
|
||||
///
|
||||
/// 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.
|
||||
pub fn ignore_all() -> Self {
|
||||
Self { types: Some(&[]), ..Default::default() }
|
||||
Self { types: Some(vec![]), ..Default::default() }
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct RoomFilter<'a> {
|
||||
pub struct RoomFilter {
|
||||
/// Include rooms that the user has left in the sync.
|
||||
///
|
||||
/// Defaults to `false`.
|
||||
@ -165,20 +144,20 @@ pub struct RoomFilter<'a> {
|
||||
|
||||
/// The per user account data to include for rooms.
|
||||
#[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.
|
||||
#[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
|
||||
/// for rooms.
|
||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||
pub ephemeral: RoomEventFilter<'a>,
|
||||
pub ephemeral: RoomEventFilter,
|
||||
|
||||
/// The state events to include for rooms.
|
||||
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
|
||||
pub state: RoomEventFilter<'a>,
|
||||
pub state: RoomEventFilter,
|
||||
|
||||
/// 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
|
||||
/// `ephemeral`, `state`, `timeline` or `account_data`.
|
||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||
pub not_rooms: &'a [OwnedRoomId],
|
||||
pub not_rooms: Vec<OwnedRoomId>,
|
||||
|
||||
/// A list of room IDs to include.
|
||||
///
|
||||
/// If this list is absent then all rooms are included. This filter is applied before the
|
||||
/// filters in `ephemeral`, `state`, `timeline` or `account_data`.
|
||||
#[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`.
|
||||
///
|
||||
/// 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).
|
||||
pub fn ignore_all() -> Self {
|
||||
Self { rooms: Some(&[]), ..Default::default() }
|
||||
Self { rooms: Some(vec![]), ..Default::default() }
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct Filter<'a> {
|
||||
pub struct Filter {
|
||||
/// A list of event types to exclude.
|
||||
///
|
||||
/// 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
|
||||
/// sequence of characters.
|
||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||
pub not_types: &'a [String],
|
||||
pub not_types: Vec<String>,
|
||||
|
||||
/// The maximum number of events to return.
|
||||
#[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.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub senders: Option<&'a [OwnedUserId]>,
|
||||
pub senders: Option<Vec<OwnedUserId>>,
|
||||
|
||||
/// 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
|
||||
/// to match any sequence of characters.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub types: Option<&'a [String]>,
|
||||
pub types: Option<Vec<String>>,
|
||||
|
||||
/// A list of sender IDs to exclude.
|
||||
///
|
||||
/// 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.
|
||||
#[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`.
|
||||
///
|
||||
/// 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.
|
||||
pub fn ignore_all() -> Self {
|
||||
Self { types: Some(&[]), ..Default::default() }
|
||||
Self { types: Some(vec![]), ..Default::default() }
|
||||
}
|
||||
|
||||
/// 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
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct FilterDefinition<'a> {
|
||||
pub struct FilterDefinition {
|
||||
/// List of event fields to include.
|
||||
///
|
||||
/// 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
|
||||
/// include more fields than were requested.
|
||||
#[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.
|
||||
///
|
||||
@ -329,18 +282,18 @@ pub struct FilterDefinition<'a> {
|
||||
|
||||
/// The presence updates to include.
|
||||
#[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.
|
||||
#[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.
|
||||
#[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`.
|
||||
///
|
||||
/// 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 {
|
||||
($ty:ident $(<$gen:tt>)?) => {
|
||||
impl $(<$gen>)? ruma_common::serde::CanBeEmpty for $ty $(<$gen>)? {
|
||||
($ty:ident) => {
|
||||
impl ruma_common::serde::CanBeEmpty for $ty {
|
||||
fn is_empty(&self) -> bool {
|
||||
self.is_empty()
|
||||
}
|
||||
@ -389,15 +331,10 @@ macro_rules! can_be_empty {
|
||||
};
|
||||
}
|
||||
|
||||
can_be_empty!(Filter<'a>);
|
||||
can_be_empty!(FilterDefinition<'a>);
|
||||
can_be_empty!(RoomEventFilter<'a>);
|
||||
can_be_empty!(RoomFilter<'a>);
|
||||
|
||||
can_be_empty!(IncomingFilter);
|
||||
can_be_empty!(IncomingFilterDefinition);
|
||||
can_be_empty!(IncomingRoomEventFilter);
|
||||
can_be_empty!(IncomingRoomFilter);
|
||||
can_be_empty!(Filter);
|
||||
can_be_empty!(FilterDefinition);
|
||||
can_be_empty!(RoomEventFilter);
|
||||
can_be_empty!(RoomFilter);
|
||||
|
||||
#[cfg(test)]
|
||||
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 super::{
|
||||
Filter, FilterDefinition, IncomingFilterDefinition, IncomingRoomEventFilter,
|
||||
IncomingRoomFilter, LazyLoadOptions, RoomEventFilter, RoomFilter, UrlFilter,
|
||||
Filter, FilterDefinition, LazyLoadOptions, RoomEventFilter, RoomFilter, UrlFilter,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@ -424,7 +360,7 @@ mod tests {
|
||||
let filter = FilterDefinition::default();
|
||||
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());
|
||||
|
||||
Ok(())
|
||||
@ -435,7 +371,7 @@ mod tests {
|
||||
let filter = RoomFilter::default();
|
||||
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());
|
||||
|
||||
Ok(())
|
||||
@ -455,7 +391,7 @@ mod tests {
|
||||
"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.not_types, vec![""; 0]);
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, UserId,
|
||||
metadata, OwnedUserId,
|
||||
};
|
||||
|
||||
use crate::filter::{FilterDefinition, IncomingFilterDefinition};
|
||||
use crate::filter::FilterDefinition;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -26,16 +26,16 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `create_filter` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The ID of the user uploading the filter.
|
||||
///
|
||||
/// The access token must be authorized to make requests for this user ID.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The filter definition.
|
||||
#[ruma_api(body)]
|
||||
pub filter: FilterDefinition<'a>,
|
||||
pub filter: FilterDefinition,
|
||||
}
|
||||
|
||||
/// Response type for the `create_filter` endpoint.
|
||||
@ -45,9 +45,9 @@ pub mod v3 {
|
||||
pub filter_id: String,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
@ -66,9 +66,9 @@ pub mod v3 {
|
||||
fn deserialize_request() {
|
||||
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()
|
||||
.method(http::Method::POST)
|
||||
.uri("https://matrix.org/_matrix/client/r0/user/@foo:bar.com/filter")
|
||||
@ -92,13 +92,16 @@ pub mod v3 {
|
||||
|
||||
use crate::filter::FilterDefinition;
|
||||
|
||||
let req = super::Request::new(user_id!("@foo:bar.com"), FilterDefinition::default())
|
||||
.try_into_http_request::<Vec<u8>>(
|
||||
"https://matrix.org",
|
||||
SendAccessToken::IfRequired("tok"),
|
||||
&[MatrixVersion::V1_1],
|
||||
)
|
||||
.unwrap();
|
||||
let req = super::Request::new(
|
||||
user_id!("@foo:bar.com").to_owned(),
|
||||
FilterDefinition::default(),
|
||||
)
|
||||
.try_into_http_request::<Vec<u8>>(
|
||||
"https://matrix.org",
|
||||
SendAccessToken::IfRequired("tok"),
|
||||
&[MatrixVersion::V1_1],
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(req.body(), b"{}");
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, UserId,
|
||||
metadata, OwnedUserId,
|
||||
};
|
||||
|
||||
use crate::filter::IncomingFilterDefinition;
|
||||
use crate::filter::FilterDefinition;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
@ -26,14 +26,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_filter` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user ID to download a filter for.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The ID of the filter to download.
|
||||
#[ruma_api(path)]
|
||||
pub filter_id: &'a str,
|
||||
pub filter_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_filter` endpoint.
|
||||
@ -41,19 +41,19 @@ pub mod v3 {
|
||||
pub struct Response {
|
||||
/// The filter definition.
|
||||
#[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.
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given filter definition.
|
||||
pub fn new(filter: IncomingFilterDefinition) -> Self {
|
||||
pub fn new(filter: FilterDefinition) -> Self {
|
||||
Self { filter }
|
||||
}
|
||||
}
|
||||
@ -77,9 +77,9 @@ pub mod v3 {
|
||||
fn serialize_response() {
|
||||
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>>()
|
||||
.unwrap();
|
||||
assert_eq!(res.body(), b"{}");
|
||||
|
@ -24,19 +24,19 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_key_changes` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The desired start point of the list.
|
||||
///
|
||||
/// Should be the next_batch field from a response to an earlier call to /sync.
|
||||
#[ruma_api(query)]
|
||||
pub from: &'a str,
|
||||
pub from: String,
|
||||
|
||||
/// The desired end point of the list.
|
||||
///
|
||||
/// Should be the next_batch field from a recent call to /sync - typically the most recent
|
||||
/// such call.
|
||||
#[ruma_api(query)]
|
||||
pub to: &'a str,
|
||||
pub to: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_key_changes` endpoint.
|
||||
@ -50,9 +50,9 @@ pub mod v3 {
|
||||
pub left: Vec<OwnedUserId>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ pub mod v3 {
|
||||
/// Request type for the `get_keys` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The time (in milliseconds) to wait when downloading keys from remote servers.
|
||||
///
|
||||
/// 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
|
||||
/// notification in that sync.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub token: Option<&'a str>,
|
||||
pub token: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `get_keys` endpoint.
|
||||
@ -84,7 +84,7 @@ pub mod v3 {
|
||||
pub user_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
|
||||
}
|
||||
|
||||
impl Request<'_> {
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
||||
serde::Raw,
|
||||
};
|
||||
|
||||
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
|
||||
use crate::uiaa::{AuthData, UiaaResponse};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -29,10 +29,10 @@ pub mod v3 {
|
||||
/// Request type for the `upload_signing_keys` endpoint.
|
||||
#[request(error = UiaaResponse)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Additional authentication information for the user-interactive authentication API.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub auth: Option<AuthData<'a>>,
|
||||
pub auth: Option<AuthData>,
|
||||
|
||||
/// The user's master key.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -58,7 +58,7 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl Request<'_> {
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedRoomId, OwnedServerName, RoomOrAliasId,
|
||||
metadata, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,21 +24,21 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `knock_room` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room the user should knock on.
|
||||
#[ruma_api(path)]
|
||||
pub room_id_or_alias: &'a RoomOrAliasId,
|
||||
pub room_id_or_alias: OwnedRoomOrAliasId,
|
||||
|
||||
/// The reason for joining a room.
|
||||
#[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.
|
||||
///
|
||||
/// One of the servers must be participating in the room.
|
||||
#[ruma_api(query)]
|
||||
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
|
||||
pub server_name: &'a [OwnedServerName],
|
||||
pub server_name: Vec<OwnedServerName>,
|
||||
}
|
||||
|
||||
/// Response type for the `knock_room` endpoint.
|
||||
@ -48,10 +48,10 @@ pub mod v3 {
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given room ID or alias.
|
||||
pub fn new(room_id_or_alias: &'a RoomOrAliasId) -> Self {
|
||||
Self { room_id_or_alias, reason: None, server_name: &[] }
|
||||
pub fn new(room_id_or_alias: OwnedRoomOrAliasId) -> Self {
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
/// The file contents to upload.
|
||||
#[ruma_api(raw_body)]
|
||||
pub file: &'a [u8],
|
||||
|
||||
pub struct Request {
|
||||
/// The name of the file being uploaded.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub filename: Option<&'a str>,
|
||||
pub filename: Option<String>,
|
||||
|
||||
/// The content type of the file being uploaded.
|
||||
#[ruma_api(header = CONTENT_TYPE)]
|
||||
pub content_type: Option<&'a str>,
|
||||
pub content_type: Option<String>,
|
||||
|
||||
/// Should the server return a blurhash or not.
|
||||
///
|
||||
@ -51,6 +47,10 @@ pub mod v3 {
|
||||
rename = "xyz.amorgan.generate_blurhash"
|
||||
)]
|
||||
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.
|
||||
@ -72,9 +72,9 @@ pub mod v3 {
|
||||
pub blurhash: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given file contents.
|
||||
pub fn new(file: &'a [u8]) -> Self {
|
||||
pub fn new(file: Vec<u8>) -> Self {
|
||||
Self {
|
||||
file,
|
||||
filename: None,
|
||||
|
@ -10,7 +10,7 @@ pub mod unstable {
|
||||
use http::header::CONTENT_TYPE;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, IdParseError, MxcUri, ServerName,
|
||||
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,22 +24,22 @@ pub mod unstable {
|
||||
|
||||
/// Request type for the `create_content_async` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The server name from the mxc:// URI (the authoritory component).
|
||||
#[ruma_api(path)]
|
||||
pub server_name: &'a ServerName,
|
||||
pub server_name: OwnedServerName,
|
||||
|
||||
/// The media ID from the mxc:// URI (the path component).
|
||||
#[ruma_api(path)]
|
||||
pub media_id: &'a str,
|
||||
pub media_id: String,
|
||||
|
||||
/// The file contents to upload.
|
||||
#[ruma_api(raw_body)]
|
||||
pub file: &'a [u8],
|
||||
pub file: Vec<u8>,
|
||||
|
||||
/// The content type of the file being uploaded.
|
||||
#[ruma_api(header = CONTENT_TYPE)]
|
||||
pub content_type: Option<&'a str>,
|
||||
pub content_type: Option<String>,
|
||||
// TODO: How does this and msc2448 (blurhash) interact?
|
||||
}
|
||||
|
||||
@ -47,16 +47,16 @@ pub mod unstable {
|
||||
#[response(error = crate::Error)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
|
||||
/// 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()?;
|
||||
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 ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, IdParseError, MxcUri, ServerName,
|
||||
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||
};
|
||||
|
||||
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
||||
@ -29,14 +29,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_media_content` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The server name from the mxc:// URI (the authoritory component).
|
||||
#[ruma_api(path)]
|
||||
pub server_name: &'a ServerName,
|
||||
pub server_name: OwnedServerName,
|
||||
|
||||
/// The media ID from the mxc:// URI (the path component).
|
||||
#[ruma_api(path)]
|
||||
pub media_id: &'a str,
|
||||
pub media_id: String,
|
||||
|
||||
/// Whether to fetch media deemed remote.
|
||||
///
|
||||
@ -91,9 +91,9 @@ pub mod v3 {
|
||||
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.
|
||||
pub fn new(media_id: &'a str, server_name: &'a ServerName) -> Self {
|
||||
pub fn new(media_id: String, server_name: OwnedServerName) -> Self {
|
||||
Self {
|
||||
media_id,
|
||||
server_name,
|
||||
@ -104,10 +104,10 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// 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()?;
|
||||
|
||||
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 ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, IdParseError, MxcUri, ServerName,
|
||||
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||
};
|
||||
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The server name from the mxc:// URI (the authoritory component).
|
||||
#[ruma_api(path)]
|
||||
pub server_name: &'a ServerName,
|
||||
pub server_name: OwnedServerName,
|
||||
|
||||
/// The media ID from the mxc:// URI (the path component).
|
||||
#[ruma_api(path)]
|
||||
pub media_id: &'a str,
|
||||
pub media_id: String,
|
||||
|
||||
/// The filename to return in the `Content-Disposition` header.
|
||||
#[ruma_api(path)]
|
||||
pub filename: &'a str,
|
||||
pub filename: String,
|
||||
|
||||
/// Whether to fetch media deemed remote.
|
||||
///
|
||||
@ -80,17 +80,22 @@ pub mod v3 {
|
||||
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.
|
||||
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 }
|
||||
}
|
||||
|
||||
/// 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()?;
|
||||
|
||||
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},
|
||||
metadata,
|
||||
serde::StringEnum,
|
||||
IdParseError, MxcUri, ServerName,
|
||||
IdParseError, MxcUri, OwnedServerName,
|
||||
};
|
||||
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The server name from the mxc:// URI (the authoritory component).
|
||||
#[ruma_api(path)]
|
||||
pub server_name: &'a ServerName,
|
||||
pub server_name: OwnedServerName,
|
||||
|
||||
/// The media ID from the mxc:// URI (the path component).
|
||||
#[ruma_api(path)]
|
||||
pub media_id: &'a str,
|
||||
pub media_id: String,
|
||||
|
||||
/// The desired resizing method.
|
||||
#[ruma_api(query)]
|
||||
@ -100,12 +100,12 @@ pub mod v3 {
|
||||
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
|
||||
/// and desired thumbnail height.
|
||||
pub fn new(
|
||||
media_id: &'a str,
|
||||
server_name: &'a ServerName,
|
||||
media_id: String,
|
||||
server_name: OwnedServerName,
|
||||
width: UInt,
|
||||
height: UInt,
|
||||
) -> Self {
|
||||
@ -123,10 +123,10 @@ pub mod v3 {
|
||||
|
||||
/// Creates a new `Request` with the given url, desired thumbnail width and
|
||||
/// 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()?;
|
||||
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// URL to get a preview of.
|
||||
#[ruma_api(query)]
|
||||
pub url: &'a str,
|
||||
pub url: String,
|
||||
|
||||
/// Preferred point in time (in milliseconds) to return a preview for.
|
||||
#[ruma_api(query)]
|
||||
@ -48,9 +48,9 @@ pub mod v3 {
|
||||
pub data: Option<Box<RawJsonValue>>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -16,36 +16,34 @@ pub mod unban_user;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use ruma_common::{
|
||||
serde::Incoming, thirdparty::Medium, OwnedServerName, OwnedServerSigningKeyId, UserId,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use ruma_common::{thirdparty::Medium, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// 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.
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[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.
|
||||
pub sender: &'a UserId,
|
||||
pub sender: OwnedUserId,
|
||||
|
||||
/// The Matrix ID of the invitee.
|
||||
pub mxid: &'a UserId,
|
||||
pub mxid: OwnedUserId,
|
||||
|
||||
/// 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.
|
||||
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
|
||||
/// and signatures.
|
||||
pub fn new(
|
||||
sender: &'a UserId,
|
||||
mxid: &'a UserId,
|
||||
token: &'a str,
|
||||
sender: OwnedUserId,
|
||||
mxid: OwnedUserId,
|
||||
token: String,
|
||||
signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
|
||||
) -> Self {
|
||||
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
|
||||
/// `Invite3pid::from` / `.into()`.
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[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.
|
||||
pub id_server: &'a str,
|
||||
pub id_server: String,
|
||||
|
||||
/// An access token registered with the identity server.
|
||||
pub id_access_token: &'a str,
|
||||
pub id_access_token: String,
|
||||
|
||||
/// Type of third party ID.
|
||||
pub medium: Medium,
|
||||
|
||||
/// Third party identifier.
|
||||
pub address: &'a str,
|
||||
pub address: String,
|
||||
}
|
||||
|
||||
/// Initial set of fields of `Invite3pid`.
|
||||
@ -78,22 +76,22 @@ pub struct Invite3pid<'a> {
|
||||
/// (non-breaking) release of the Matrix specification.
|
||||
#[derive(Debug)]
|
||||
#[allow(clippy::exhaustive_structs)]
|
||||
pub struct Invite3pidInit<'a> {
|
||||
pub struct Invite3pidInit {
|
||||
/// 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.
|
||||
pub id_access_token: &'a str,
|
||||
pub id_access_token: String,
|
||||
|
||||
/// Type of third party ID.
|
||||
pub medium: Medium,
|
||||
|
||||
/// Third party identifier.
|
||||
pub address: &'a str,
|
||||
pub address: String,
|
||||
}
|
||||
|
||||
impl<'a> From<Invite3pidInit<'a>> for Invite3pid<'a> {
|
||||
fn from(init: Invite3pidInit<'a>) -> Self {
|
||||
impl From<Invite3pidInit> for Invite3pid {
|
||||
fn from(init: Invite3pidInit) -> Self {
|
||||
let Invite3pidInit { id_server, id_access_token, medium, address } = init;
|
||||
Self { id_server, id_access_token, medium, address }
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId, UserId,
|
||||
metadata, OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,17 +24,17 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `ban_user` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to kick the user from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The user to ban.
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The reason for banning the user.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<&'a str>,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `ban_user` endpoint.
|
||||
@ -42,9 +42,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `forget_room` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to forget.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
/// Response type for the `forget_room` endpoint.
|
||||
@ -35,9 +35,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
events::room::member::RoomMemberEvent,
|
||||
metadata,
|
||||
serde::{Raw, StringEnum},
|
||||
RoomId,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
@ -29,10 +29,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_member_events` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to get the member events for.
|
||||
#[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.
|
||||
///
|
||||
@ -40,7 +40,7 @@ pub mod v3 {
|
||||
/// API.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub at: Option<&'a str>,
|
||||
pub at: Option<String>,
|
||||
|
||||
/// The kind of memberships to filter for.
|
||||
///
|
||||
@ -66,9 +66,9 @@ pub mod v3 {
|
||||
pub chunk: Vec<Raw<RoomMemberEvent>>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ pub mod v3 {
|
||||
mod tests {
|
||||
use ruma_common::api::IncomingRequest as _;
|
||||
|
||||
use super::{IncomingRequest, MembershipEventFilter};
|
||||
use super::{MembershipEventFilter, Request};
|
||||
|
||||
#[test]
|
||||
fn deserialization() {
|
||||
@ -121,7 +121,7 @@ pub mod v3 {
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let req = IncomingRequest::try_from_http_request(
|
||||
let req = Request::try_from_http_request(
|
||||
http::Request::builder().uri(uri).body(&[] as &[u8]).unwrap(),
|
||||
&["!dummy:example.org"],
|
||||
)
|
||||
|
@ -14,13 +14,11 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
serde::Incoming,
|
||||
RoomId, UserId,
|
||||
metadata, OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::membership::{IncomingInvite3pid, Invite3pid};
|
||||
use crate::membership::Invite3pid;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -34,18 +32,18 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `invite_user` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room where the user should be invited.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The user to invite.
|
||||
#[serde(flatten)]
|
||||
pub recipient: InvitationRecipient<'a>,
|
||||
pub recipient: InvitationRecipient,
|
||||
|
||||
/// Optional reason for inviting the user.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<&'a str>,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `invite_user` endpoint.
|
||||
@ -53,9 +51,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
@ -68,18 +66,18 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// 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)]
|
||||
#[serde(untagged)]
|
||||
pub enum InvitationRecipient<'a> {
|
||||
pub enum InvitationRecipient {
|
||||
/// Used to invite user by their Matrix identifier.
|
||||
UserId {
|
||||
/// Matrix identifier of user.
|
||||
user_id: &'a UserId,
|
||||
user_id: OwnedUserId,
|
||||
},
|
||||
|
||||
/// Used to invite user by a third party identifier.
|
||||
ThirdPartyId(Invite3pid<'a>),
|
||||
ThirdPartyId(Invite3pid),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -88,25 +86,24 @@ pub mod v3 {
|
||||
use ruma_common::thirdparty::Medium;
|
||||
use serde_json::{from_value as from_json_value, json};
|
||||
|
||||
use super::IncomingInvitationRecipient;
|
||||
use super::InvitationRecipient;
|
||||
|
||||
#[test]
|
||||
fn deserialize_invite_by_user_id() {
|
||||
let incoming = from_json_value::<IncomingInvitationRecipient>(
|
||||
json!({ "user_id": "@carl:example.org" }),
|
||||
)
|
||||
.unwrap();
|
||||
let incoming =
|
||||
from_json_value::<InvitationRecipient>(json!({ "user_id": "@carl:example.org" }))
|
||||
.unwrap();
|
||||
|
||||
let user_id = assert_matches!(
|
||||
incoming,
|
||||
IncomingInvitationRecipient::UserId { user_id } => user_id
|
||||
InvitationRecipient::UserId { user_id } => user_id
|
||||
);
|
||||
assert_eq!(user_id, "@carl:example.org");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_invite_by_3pid() {
|
||||
let incoming = from_json_value::<IncomingInvitationRecipient>(json!({
|
||||
let incoming = from_json_value::<InvitationRecipient>(json!({
|
||||
"id_server": "example.org",
|
||||
"id_access_token": "abcdefghijklmnop",
|
||||
"medium": "email",
|
||||
@ -116,7 +113,7 @@ pub mod v3 {
|
||||
|
||||
let third_party_id = assert_matches!(
|
||||
incoming,
|
||||
IncomingInvitationRecipient::ThirdPartyId(id) => id
|
||||
InvitationRecipient::ThirdPartyId(id) => id
|
||||
);
|
||||
|
||||
assert_eq!(third_party_id.id_server, "example.org");
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedRoomId, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::membership::{IncomingThirdPartySigned, ThirdPartySigned};
|
||||
use crate::membership::ThirdPartySigned;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
@ -26,19 +26,19 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `join_room_by_id` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room where the user should be invited.
|
||||
#[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
|
||||
/// party identity which has been invited to the room.
|
||||
#[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.
|
||||
#[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.
|
||||
@ -48,9 +48,9 @@ pub mod v3 {
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
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! {
|
||||
method: POST,
|
||||
@ -26,26 +26,26 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `join_room_by_id_or_alias` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room where the user should be invited.
|
||||
#[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.
|
||||
///
|
||||
/// One of the servers must be participating in the room.
|
||||
#[ruma_api(query)]
|
||||
#[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
|
||||
/// party identity which has been invited to the room.
|
||||
#[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.
|
||||
#[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.
|
||||
@ -55,10 +55,10 @@ pub mod v3 {
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given room ID or alias ID.
|
||||
pub fn new(room_id_or_alias: &'a RoomOrAliasId) -> Self {
|
||||
Self { room_id_or_alias, server_name: &[], third_party_signed: None, reason: None }
|
||||
pub fn new(room_id_or_alias: OwnedRoomOrAliasId) -> Self {
|
||||
Self { room_id_or_alias, server_name: vec![], third_party_signed: None, reason: None }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedMxcUri, OwnedUserId, RoomId,
|
||||
metadata, OwnedMxcUri, OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -28,10 +28,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `joined_members` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to get the members of.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
}
|
||||
|
||||
/// Response type for the `joined_members` endpoint.
|
||||
@ -42,9 +42,9 @@ pub mod v3 {
|
||||
pub joined: BTreeMap<OwnedUserId, RoomMember>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId, UserId,
|
||||
metadata, OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,17 +24,17 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `kick_user` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to kick the user from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The user to kick.
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The reason for kicking the user.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<&'a str>,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `kick_user` endpoint.
|
||||
@ -42,9 +42,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId,
|
||||
metadata, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,14 +24,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `leave_room` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to leave.
|
||||
#[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.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<&'a str>,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `leave_room` endpoint.
|
||||
@ -39,9 +39,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod unstable {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedRoomId, UserId,
|
||||
metadata, OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -23,10 +23,10 @@ pub mod unstable {
|
||||
|
||||
/// Request type for the `mutual_rooms` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user to search mutual rooms for.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `mutual_rooms` endpoint.
|
||||
@ -36,9 +36,9 @@ pub mod unstable {
|
||||
pub joined: Vec<OwnedRoomId>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, RoomId, UserId,
|
||||
metadata, OwnedRoomId, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,17 +24,17 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `unban_user` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to unban the user from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The user to unban.
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// Optional reason for unbanning the user.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<&'a str>,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `unban_user` endpoint.
|
||||
@ -42,9 +42,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,10 @@ pub mod v3 {
|
||||
events::{AnyStateEvent, AnyTimelineEvent},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
RoomId,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
filter::{IncomingRoomEventFilter, RoomEventFilter},
|
||||
Direction,
|
||||
};
|
||||
use crate::{filter::RoomEventFilter, Direction};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
@ -33,10 +30,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_message_events` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to get events from.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// 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
|
||||
/// history visible to the user, depending on the value of [`dir`][Self::dir].
|
||||
#[ruma_api(query)]
|
||||
pub from: Option<&'a str>,
|
||||
pub from: Option<String>,
|
||||
|
||||
/// The token to stop returning events at.
|
||||
///
|
||||
@ -56,7 +53,7 @@ pub mod v3 {
|
||||
/// this endpoint.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ruma_api(query)]
|
||||
pub to: Option<&'a str>,
|
||||
pub to: Option<String>,
|
||||
|
||||
/// The direction to return events from.
|
||||
#[ruma_api(query)]
|
||||
@ -76,7 +73,7 @@ pub mod v3 {
|
||||
default,
|
||||
skip_serializing_if = "RoomEventFilter::is_empty"
|
||||
)]
|
||||
pub filter: RoomEventFilter<'a>,
|
||||
pub filter: RoomEventFilter,
|
||||
}
|
||||
|
||||
/// Response type for the `get_message_events` endpoint.
|
||||
@ -99,11 +96,11 @@ pub mod v3 {
|
||||
pub state: Vec<Raw<AnyStateEvent>>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given room ID and direction.
|
||||
///
|
||||
/// 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 {
|
||||
room_id,
|
||||
from: None,
|
||||
@ -123,11 +120,11 @@ pub mod v3 {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use ruma_client_api::message::get_message_events;
|
||||
/// # let room_id = ruma_common::room_id!("!a:example.org");
|
||||
/// # let token = "prev_batch token";
|
||||
/// # let room_id = ruma_common::room_id!("!a:example.org").to_owned();
|
||||
/// # let token = "prev_batch token".to_owned();
|
||||
/// 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)
|
||||
}
|
||||
|
||||
@ -140,11 +137,11 @@ pub mod v3 {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use ruma_client_api::message::get_message_events;
|
||||
/// # let room_id = ruma_common::room_id!("!a:example.org");
|
||||
/// # let token = "end token";
|
||||
/// # let room_id = ruma_common::room_id!("!a:example.org").to_owned();
|
||||
/// # let token = "end token".to_owned();
|
||||
/// 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)
|
||||
}
|
||||
|
||||
@ -152,7 +149,7 @@ pub mod v3 {
|
||||
///
|
||||
/// 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.
|
||||
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 }
|
||||
}
|
||||
}
|
||||
@ -189,23 +186,23 @@ pub mod v3 {
|
||||
|
||||
#[test]
|
||||
fn serialize_some_room_event_filter() {
|
||||
let room_id = room_id!("!roomid:example.org");
|
||||
let rooms = &[room_id.to_owned()];
|
||||
let room_id = room_id!("!roomid:example.org").to_owned();
|
||||
let rooms = vec![room_id.to_owned()];
|
||||
let filter = RoomEventFilter {
|
||||
lazy_load_options: LazyLoadOptions::Enabled { include_redundant_members: true },
|
||||
rooms: Some(rooms),
|
||||
not_rooms: &[
|
||||
not_rooms: vec![
|
||||
room_id!("!room:example.org").to_owned(),
|
||||
room_id!("!room2:example.org").to_owned(),
|
||||
room_id!("!room3:example.org").to_owned(),
|
||||
],
|
||||
not_types: &["type".into()],
|
||||
not_types: vec!["type".into()],
|
||||
..Default::default()
|
||||
};
|
||||
let req = Request {
|
||||
room_id,
|
||||
from: Some("token"),
|
||||
to: Some("token2"),
|
||||
from: Some("token".to_owned()),
|
||||
to: Some("token2".to_owned()),
|
||||
dir: Direction::Backward,
|
||||
limit: uint!(0),
|
||||
filter,
|
||||
@ -230,11 +227,11 @@ pub mod v3 {
|
||||
|
||||
#[test]
|
||||
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 {
|
||||
room_id,
|
||||
from: Some("token"),
|
||||
to: Some("token2"),
|
||||
from: Some("token".to_owned()),
|
||||
to: Some("token2".to_owned()),
|
||||
dir: Direction::Backward,
|
||||
limit: uint!(0),
|
||||
filter: RoomEventFilter::default(),
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
events::{AnyMessageLikeEventContent, MessageLikeEventContent, MessageLikeEventType},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, TransactionId,
|
||||
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedTransactionId,
|
||||
};
|
||||
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(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room to send the event to.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The type of event to send.
|
||||
#[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
|
||||
#[ruma_api(path)]
|
||||
pub txn_id: &'a TransactionId,
|
||||
pub txn_id: OwnedTransactionId,
|
||||
|
||||
/// The event content to send.
|
||||
#[ruma_api(body)]
|
||||
@ -72,7 +72,7 @@ pub mod v3 {
|
||||
pub event_id: OwnedEventId,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given room id, transaction id and event content.
|
||||
///
|
||||
/// # Errors
|
||||
@ -80,9 +80,9 @@ pub mod v3 {
|
||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||
pub fn new<T>(
|
||||
room_id: &'a RoomId,
|
||||
txn_id: &'a TransactionId,
|
||||
content: &'a T,
|
||||
room_id: OwnedRoomId,
|
||||
txn_id: OwnedTransactionId,
|
||||
content: &T,
|
||||
) -> serde_json::Result<Self>
|
||||
where
|
||||
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
|
||||
/// content.
|
||||
pub fn new_raw(
|
||||
room_id: &'a RoomId,
|
||||
txn_id: &'a TransactionId,
|
||||
room_id: OwnedRoomId,
|
||||
txn_id: OwnedTransactionId,
|
||||
event_type: MessageLikeEventType,
|
||||
body: Raw<AnyMessageLikeEventContent>,
|
||||
) -> Self {
|
||||
|
@ -13,7 +13,7 @@ pub mod v3 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
presence::PresenceState,
|
||||
UserId,
|
||||
OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -28,10 +28,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_presence` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose presence state will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_presence` endpoint.
|
||||
@ -57,9 +57,9 @@ pub mod v3 {
|
||||
pub presence: PresenceState,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
||||
api::{request, response, Metadata},
|
||||
metadata,
|
||||
presence::PresenceState,
|
||||
UserId,
|
||||
OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -26,17 +26,17 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_presence` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose presence state will be updated.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The new presence state.
|
||||
pub presence: PresenceState,
|
||||
|
||||
/// The status message to attach to this state.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub status_msg: Option<&'a str>,
|
||||
pub status_msg: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `set_presence` endpoint.
|
||||
@ -44,9 +44,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedMxcUri, UserId,
|
||||
metadata, OwnedMxcUri, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_avatar_url` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose avatar URL will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_avatar_url` endpoint.
|
||||
@ -54,9 +54,9 @@ pub mod v3 {
|
||||
pub blurhash: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, UserId,
|
||||
metadata, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_display_name` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose display name will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_display_name` endpoint.
|
||||
@ -39,9 +39,9 @@ pub mod v3 {
|
||||
pub displayname: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, OwnedMxcUri, UserId,
|
||||
metadata, OwnedMxcUri, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_profile` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose profile will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
}
|
||||
|
||||
/// Response type for the `get_profile` endpoint.
|
||||
@ -58,9 +58,9 @@ pub mod v3 {
|
||||
pub blurhash: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, MxcUri, UserId,
|
||||
metadata, OwnedMxcUri, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,10 +24,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_avatar_url` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose avatar URL will be set.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// 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"))]
|
||||
pub avatar_url: Option<&'a MxcUri>,
|
||||
pub avatar_url: Option<OwnedMxcUri>,
|
||||
|
||||
/// 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).
|
||||
#[cfg(feature = "unstable-msc2448")]
|
||||
#[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.
|
||||
@ -60,9 +60,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 {
|
||||
user_id,
|
||||
avatar_url,
|
||||
@ -83,11 +83,11 @@ pub mod v3 {
|
||||
mod tests {
|
||||
use ruma_common::api::IncomingRequest as _;
|
||||
|
||||
use super::IncomingRequest;
|
||||
use super::Request;
|
||||
|
||||
#[test]
|
||||
fn deserialize_unset_request() {
|
||||
let req = IncomingRequest::try_from_http_request(
|
||||
let req = Request::try_from_http_request(
|
||||
http::Request::builder()
|
||||
.method("PUT")
|
||||
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
||||
@ -101,7 +101,7 @@ pub mod v3 {
|
||||
|
||||
#[cfg(feature = "compat")]
|
||||
{
|
||||
let req = IncomingRequest::try_from_http_request(
|
||||
let req = Request::try_from_http_request(
|
||||
http::Request::builder()
|
||||
.method("PUT")
|
||||
.uri("https://bar.org/_matrix/client/r0/profile/@foo:bar.org/avatar_url")
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, UserId,
|
||||
metadata, OwnedUserId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,14 +24,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_display_name` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The user whose display name will be set.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: OwnedUserId,
|
||||
|
||||
/// The new display name for the user.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub displayname: Option<&'a str>,
|
||||
pub displayname: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `set_display_name` endpoint.
|
||||
@ -39,9 +39,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `delete_pushrule` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to delete from.
|
||||
#[ruma_api(path)]
|
||||
pub scope: RuleScope,
|
||||
@ -37,7 +37,7 @@ pub mod v3 {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: &'a str,
|
||||
pub rule_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `delete_pushrule` endpoint.
|
||||
@ -45,9 +45,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ pub mod v3 {
|
||||
/// Request type for the `get_notifications` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
#[derive(Default)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// Pagination token given to retrieve the next set of events.
|
||||
#[ruma_api(query)]
|
||||
#[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.
|
||||
#[ruma_api(query)]
|
||||
@ -48,7 +48,7 @@ pub mod v3 {
|
||||
/// tweak set.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub only: Option<&'a str>,
|
||||
pub only: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `get_notifications` endpoint.
|
||||
@ -65,7 +65,7 @@ pub mod v3 {
|
||||
pub notifications: Vec<Notification>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_pushrule` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to fetch rules from.
|
||||
#[ruma_api(path)]
|
||||
pub scope: RuleScope,
|
||||
@ -37,7 +37,7 @@ pub mod v3 {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: &'a str,
|
||||
pub rule_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_pushrule` endpoint.
|
||||
@ -48,9 +48,9 @@ pub mod v3 {
|
||||
pub rule: PushRule,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_pushrule_actions` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to fetch a rule from.
|
||||
#[ruma_api(path)]
|
||||
pub scope: RuleScope,
|
||||
@ -38,7 +38,7 @@ pub mod v3 {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: &'a str,
|
||||
pub rule_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_pushrule_actions` endpoint.
|
||||
@ -48,9 +48,9 @@ pub mod v3 {
|
||||
pub actions: Vec<Action>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `get_pushrule_enabled` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to fetch a rule from.
|
||||
#[ruma_api(path)]
|
||||
pub scope: RuleScope,
|
||||
@ -37,7 +37,7 @@ pub mod v3 {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: &'a str,
|
||||
pub rule_id: String,
|
||||
}
|
||||
|
||||
/// Response type for the `get_pushrule_enabled` endpoint.
|
||||
@ -47,9 +47,9 @@ pub mod v3 {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ pub mod v3 {
|
||||
api::{response, Metadata},
|
||||
metadata,
|
||||
push::{Action, NewPushRule, PushCondition},
|
||||
serde::Incoming,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -28,10 +27,9 @@ pub mod v3 {
|
||||
};
|
||||
|
||||
/// Request type for the `set_pushrule` endpoint.
|
||||
#[derive(Clone, Debug, Incoming)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to set the rule in.
|
||||
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
|
||||
/// 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
|
||||
/// rule.
|
||||
pub after: Option<&'a str>,
|
||||
pub after: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `set_pushrule` endpoint.
|
||||
@ -52,7 +50,7 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given scope and rule.
|
||||
pub fn new(scope: RuleScope, rule: NewPushRule) -> Self {
|
||||
Self { scope, rule, before: None, after: None }
|
||||
@ -67,7 +65,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
impl<'a> ruma_common::api::OutgoingRequest for Request<'a> {
|
||||
impl ruma_common::api::OutgoingRequest for Request {
|
||||
type EndpointError = crate::Error;
|
||||
type IncomingResponse = Response;
|
||||
|
||||
@ -113,7 +111,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl ruma_common::api::IncomingRequest for IncomingRequest {
|
||||
impl ruma_common::api::IncomingRequest for Request {
|
||||
type EndpointError = crate::Error;
|
||||
type OutgoingResponse = Response;
|
||||
|
||||
@ -196,12 +194,12 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct RequestQuery<'a> {
|
||||
struct RequestQuery {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
before: Option<&'a str>,
|
||||
before: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
after: Option<&'a str>,
|
||||
after: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
|
@ -28,7 +28,7 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_pushrule_actions` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to fetch a rule from.
|
||||
#[ruma_api(path)]
|
||||
pub scope: RuleScope,
|
||||
@ -39,7 +39,7 @@ pub mod v3 {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: &'a str,
|
||||
pub rule_id: String,
|
||||
|
||||
/// The actions to perform for this rule
|
||||
pub actions: Vec<Action>,
|
||||
@ -50,12 +50,12 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and actions.
|
||||
pub fn new(
|
||||
scope: RuleScope,
|
||||
kind: RuleKind,
|
||||
rule_id: &'a str,
|
||||
rule_id: String,
|
||||
actions: Vec<Action>,
|
||||
) -> Self {
|
||||
Self { scope, kind, rule_id, actions }
|
||||
|
@ -26,7 +26,7 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_pushrule_enabled` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The scope to fetch a rule from.
|
||||
#[ruma_api(path)]
|
||||
pub scope: RuleScope,
|
||||
@ -37,7 +37,7 @@ pub mod v3 {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: &'a str,
|
||||
pub rule_id: String,
|
||||
|
||||
/// Whether the push rule is enabled or not.
|
||||
pub enabled: bool,
|
||||
@ -48,19 +48,19 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, EventId, RoomId,
|
||||
metadata, OwnedEventId, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -29,10 +29,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `set_read_marker` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room ID to set the read marker in for the user.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The event ID the fully-read marker should be located at.
|
||||
///
|
||||
@ -44,7 +44,7 @@ pub mod v3 {
|
||||
/// [`create_receipt`]: crate::receipt::create_receipt
|
||||
/// [`ReceiptType::FullyRead`]: crate::receipt::create_receipt::v3::ReceiptType::FullyRead
|
||||
#[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.
|
||||
///
|
||||
@ -54,7 +54,7 @@ pub mod v3 {
|
||||
/// [`create_receipt`]: crate::receipt::create_receipt
|
||||
/// [`ReceiptType::Read`]: crate::receipt::create_receipt::v3::ReceiptType::Read
|
||||
#[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.
|
||||
///
|
||||
@ -64,7 +64,7 @@ pub mod v3 {
|
||||
/// [`create_receipt`]: crate::receipt::create_receipt
|
||||
/// [`ReceiptType::ReadPrivate`]: crate::receipt::create_receipt::v3::ReceiptType::ReadPrivate
|
||||
#[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.
|
||||
@ -72,9 +72,9 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub mod v3 {
|
||||
events::receipt::ReceiptThread,
|
||||
metadata,
|
||||
serde::{OrdAsRefStr, PartialEqAsRefStr, PartialOrdAsRefStr, StringEnum},
|
||||
EventId, RoomId,
|
||||
OwnedEventId, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
@ -29,10 +29,10 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `create_receipt` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The room in which to send the event.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The type of receipt to send.
|
||||
#[ruma_api(path)]
|
||||
@ -40,7 +40,7 @@ pub mod v3 {
|
||||
|
||||
/// The event ID to acknowledge up to.
|
||||
#[ruma_api(path)]
|
||||
pub event_id: &'a EventId,
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// The thread this receipt applies to.
|
||||
///
|
||||
@ -61,9 +61,13 @@ pub mod v3 {
|
||||
#[derive(Default)]
|
||||
pub struct Response {}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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() }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
metadata, EventId, OwnedEventId, RoomId, TransactionId,
|
||||
metadata, OwnedEventId, OwnedRoomId, OwnedTransactionId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
@ -24,14 +24,14 @@ pub mod v3 {
|
||||
|
||||
/// Request type for the `redact_event` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request<'a> {
|
||||
pub struct Request {
|
||||
/// The ID of the room of the event to redact.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The ID of the event to redact.
|
||||
#[ruma_api(path)]
|
||||
pub event_id: &'a EventId,
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// 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
|
||||
#[ruma_api(path)]
|
||||
pub txn_id: &'a TransactionId,
|
||||
pub txn_id: OwnedTransactionId,
|
||||
|
||||
/// The reason for the redaction.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<&'a str>,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
/// Response type for the `redact_event` endpoint.
|
||||
@ -57,9 +57,13 @@ pub mod v3 {
|
||||
pub event_id: OwnedEventId,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
impl Request {
|
||||
/// 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 }
|
||||
}
|
||||
}
|
||||
|
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