client-api: Stabilize MSC3316
This commit is contained in:
parent
80a8dcf28a
commit
fdb45296c5
@ -10,7 +10,7 @@ Improvements:
|
|||||||
|
|
||||||
* Add support for refresh tokens (MSC2918)
|
* Add support for refresh tokens (MSC2918)
|
||||||
* Add `ErrorKind::{UnableToAuthorizeJoin, UnableToGrantJoin}` encountered for restricted rooms
|
* Add `ErrorKind::{UnableToAuthorizeJoin, UnableToGrantJoin}` encountered for restricted rooms
|
||||||
* Add unstable support for timestamp massaging (MSC3316)
|
* Add support for timestamp massaging (MSC3316)
|
||||||
* Add support for querying relating events (MSC2675)
|
* Add support for querying relating events (MSC2675)
|
||||||
* Move `filter::RelationType` to `ruma_common::events::relations`
|
* Move `filter::RelationType` to `ruma_common::events::relations`
|
||||||
* Add unstable support for discovering an OpenID Connect server (MSC2965)
|
* Add unstable support for discovering an OpenID Connect server (MSC2965)
|
||||||
|
@ -25,7 +25,6 @@ unstable-msc2654 = []
|
|||||||
unstable-msc2676 = []
|
unstable-msc2676 = []
|
||||||
unstable-msc2677 = []
|
unstable-msc2677 = []
|
||||||
unstable-msc2965 = []
|
unstable-msc2965 = []
|
||||||
unstable-msc3316 = []
|
|
||||||
unstable-msc3440 = []
|
unstable-msc3440 = []
|
||||||
unstable-msc3488 = []
|
unstable-msc3488 = []
|
||||||
client = []
|
client = []
|
||||||
|
@ -5,13 +5,11 @@ pub mod v3 {
|
|||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid
|
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
use ruma_common::MilliSecondsSinceUnixEpoch;
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::ruma_api,
|
api::ruma_api,
|
||||||
events::{AnyMessageLikeEventContent, MessageLikeEventContent, MessageLikeEventType},
|
events::{AnyMessageLikeEventContent, MessageLikeEventContent, MessageLikeEventType},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
OwnedEventId, RoomId, TransactionId,
|
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, TransactionId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||||
|
|
||||||
@ -54,8 +52,7 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// Note that this does not change the position of the event in the timeline.
|
/// Note that this does not change the position of the event in the timeline.
|
||||||
///
|
///
|
||||||
/// [timestamp massaging]: https://github.com/matrix-org/matrix-spec-proposals/pull/3316
|
/// [timestamp massaging]: https://spec.matrix.org/v1.3/application-service-api/#timestamp-massaging
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename = "ts")]
|
#[serde(skip_serializing_if = "Option::is_none", rename = "ts")]
|
||||||
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
|
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
|
||||||
@ -89,7 +86,6 @@ pub mod v3 {
|
|||||||
txn_id,
|
txn_id,
|
||||||
event_type: content.event_type(),
|
event_type: content.event_type(),
|
||||||
body: Raw::from_json(to_raw_json_value(content)?),
|
body: Raw::from_json(to_raw_json_value(content)?),
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
timestamp: None,
|
timestamp: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -102,14 +98,7 @@ pub mod v3 {
|
|||||||
event_type: MessageLikeEventType,
|
event_type: MessageLikeEventType,
|
||||||
body: Raw<AnyMessageLikeEventContent>,
|
body: Raw<AnyMessageLikeEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self { room_id, event_type, txn_id, body, timestamp: None }
|
||||||
room_id,
|
|
||||||
event_type,
|
|
||||||
txn_id,
|
|
||||||
body,
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
timestamp: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,11 @@ pub mod v3 {
|
|||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
|
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
use ruma_common::MilliSecondsSinceUnixEpoch;
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::ruma_api,
|
api::ruma_api,
|
||||||
events::{AnyStateEventContent, StateEventContent, StateEventType},
|
events::{AnyStateEventContent, StateEventContent, StateEventType},
|
||||||
serde::{Incoming, Raw},
|
serde::{Incoming, Raw},
|
||||||
OwnedEventId, RoomId,
|
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||||
|
|
||||||
@ -60,8 +58,7 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// Note that this does not change the position of the event in the timeline.
|
/// Note that this does not change the position of the event in the timeline.
|
||||||
///
|
///
|
||||||
/// [timestamp massaging]: https://github.com/matrix-org/matrix-spec-proposals/pull/3316
|
/// [timestamp massaging]: https://spec.matrix.org/v1.3/application-service-api/#timestamp-massaging
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
|
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +82,6 @@ pub mod v3 {
|
|||||||
state_key,
|
state_key,
|
||||||
event_type: content.event_type(),
|
event_type: content.event_type(),
|
||||||
body: Raw::from_json(to_raw_json_value(content)?),
|
body: Raw::from_json(to_raw_json_value(content)?),
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
timestamp: None,
|
timestamp: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -98,14 +94,7 @@ pub mod v3 {
|
|||||||
state_key: &'a str,
|
state_key: &'a str,
|
||||||
body: Raw<AnyStateEventContent>,
|
body: Raw<AnyStateEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self { room_id, event_type, state_key, body, timestamp: None }
|
||||||
room_id,
|
|
||||||
event_type,
|
|
||||||
state_key,
|
|
||||||
body,
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
timestamp: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +149,9 @@ pub mod v3 {
|
|||||||
url.push_str(&Cow::from(utf8_percent_encode(self.state_key, NON_ALPHANUMERIC)));
|
url.push_str(&Cow::from(utf8_percent_encode(self.state_key, NON_ALPHANUMERIC)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
let request_query = RequestQuery { timestamp: self.timestamp };
|
||||||
{
|
url.push('?');
|
||||||
let request_query = RequestQuery { timestamp: self.timestamp };
|
url.push_str(&ruma_common::serde::urlencoded::to_string(request_query)?);
|
||||||
url.push('?');
|
|
||||||
url.push_str(&ruma_common::serde::urlencoded::to_string(request_query)?);
|
|
||||||
}
|
|
||||||
|
|
||||||
let http_request = http::Request::builder()
|
let http_request = http::Request::builder()
|
||||||
.method(http::Method::PUT)
|
.method(http::Method::PUT)
|
||||||
@ -225,33 +211,24 @@ pub mod v3 {
|
|||||||
(a, b, "".into())
|
(a, b, "".into())
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
let request_query: RequestQuery =
|
let request_query: RequestQuery =
|
||||||
ruma_common::serde::urlencoded::from_str(request.uri().query().unwrap_or(""))?;
|
ruma_common::serde::urlencoded::from_str(request.uri().query().unwrap_or(""))?;
|
||||||
|
|
||||||
let body = serde_json::from_slice(request.body().as_ref())?;
|
let body = serde_json::from_slice(request.body().as_ref())?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { room_id, event_type, state_key, body, timestamp: request_query.timestamp })
|
||||||
room_id,
|
|
||||||
event_type,
|
|
||||||
state_key,
|
|
||||||
body,
|
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
timestamp: request_query.timestamp,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data in the request's query string.
|
/// Data in the request's query string.
|
||||||
#[cfg(feature = "unstable-msc3316")]
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(feature = "client", derive(serde::Serialize))]
|
#[cfg_attr(feature = "client", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "server", derive(serde::Deserialize))]
|
#[cfg_attr(feature = "server", derive(serde::Deserialize))]
|
||||||
struct RequestQuery {
|
struct RequestQuery {
|
||||||
/// Timestamp to use for the `origin_server_ts` of the event.
|
/// Timestamp to use for the `origin_server_ts` of the event.
|
||||||
#[serde(
|
#[serde(
|
||||||
rename = "org.matrix.msc3316.ts",
|
alias = "org.matrix.msc3316.ts",
|
||||||
alias = "ts",
|
rename = "ts",
|
||||||
skip_serializing_if = "Option::is_none"
|
skip_serializing_if = "Option::is_none"
|
||||||
)]
|
)]
|
||||||
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
|
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
|
||||||
|
@ -137,7 +137,6 @@ unstable-msc2746 = ["ruma-common/unstable-msc2746"]
|
|||||||
unstable-msc2870 = ["ruma-signatures?/unstable-msc2870"]
|
unstable-msc2870 = ["ruma-signatures?/unstable-msc2870"]
|
||||||
unstable-msc3245 = ["ruma-common/unstable-msc3245"]
|
unstable-msc3245 = ["ruma-common/unstable-msc3245"]
|
||||||
unstable-msc3246 = ["ruma-common/unstable-msc3246"]
|
unstable-msc3246 = ["ruma-common/unstable-msc3246"]
|
||||||
unstable-msc3316 = ["ruma-client-api?/unstable-msc3316"]
|
|
||||||
unstable-msc3381 = ["ruma-common/unstable-msc3381"]
|
unstable-msc3381 = ["ruma-common/unstable-msc3381"]
|
||||||
unstable-msc3440 = [
|
unstable-msc3440 = [
|
||||||
"ruma-client-api?/unstable-msc3440",
|
"ruma-client-api?/unstable-msc3440",
|
||||||
@ -168,7 +167,6 @@ __ci = [
|
|||||||
"unstable-msc2870",
|
"unstable-msc2870",
|
||||||
"unstable-msc3245",
|
"unstable-msc3245",
|
||||||
"unstable-msc3246",
|
"unstable-msc3246",
|
||||||
"unstable-msc3316",
|
|
||||||
"unstable-msc3381",
|
"unstable-msc3381",
|
||||||
"unstable-msc3440",
|
"unstable-msc3440",
|
||||||
"unstable-msc3488",
|
"unstable-msc3488",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user