Remove origin field from transactions and pdus for #[feature = "unstable-pre-spec"]

See https://github.com/matrix-org/synapse/issues/3816

Co-authored-by: Timo <timo@koesters.xyz>
This commit is contained in:
Jonas Platte 2020-09-17 19:50:39 +02:00
parent 192db0371c
commit 15e1a4bea8
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
6 changed files with 20 additions and 1 deletions

View File

@ -31,6 +31,7 @@ trybuild = "1.0.31"
[features]
unstable-exhaustive-types = []
unstable-pre-spec = []
[[bench]]
name = "event_deserialize"

View File

@ -38,6 +38,7 @@ pub struct RoomV1Pdu {
/// The user id of the user who sent this event.
pub sender: UserId,
#[cfg(not(feature = "unstable-pre-spec"))]
/// The `server_name` of the homeserver that created this event.
pub origin: String,
@ -96,6 +97,7 @@ pub struct RoomV3Pdu {
/// The user id of the user who sent this event.
pub sender: UserId,
#[cfg(not(feature = "unstable-pre-spec"))]
/// The `server_name` of the homeserver that created this event.
pub origin: String,
@ -172,6 +174,7 @@ pub struct RoomV1PduStub {
/// The user id of the user who sent this event.
pub sender: UserId,
#[cfg(not(feature = "unstable-pre-spec"))]
/// The `server_name` of the homeserver that created this event.
pub origin: String,
@ -226,6 +229,7 @@ impl RoomV1PduStub {
event_id,
room_id,
sender: self.sender,
#[cfg(not(feature = "unstable-pre-spec"))]
origin: self.origin,
origin_server_ts: self.origin_server_ts,
kind: self.kind,
@ -248,6 +252,7 @@ pub struct RoomV3PduStub {
/// The user id of the user who sent this event.
pub sender: UserId,
#[cfg(not(feature = "unstable-pre-spec"))]
/// The `server_name` of the homeserver that created this event.
pub origin: String,
@ -301,6 +306,7 @@ impl RoomV3PduStub {
RoomV3Pdu {
room_id,
sender: self.sender,
#[cfg(not(feature = "unstable-pre-spec"))]
origin: self.origin,
origin_server_ts: self.origin_server_ts,
kind: self.kind,

View File

@ -11,6 +11,7 @@ use ruma_events::{
use ruma_identifiers::{event_id, room_id, server_key_id, server_name, user_id};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn serialize_stub_as_v1() {
let mut signatures = BTreeMap::new();
@ -74,6 +75,7 @@ fn serialize_stub_as_v1() {
assert_eq!(to_json_value(&pdu_stub).unwrap(), json);
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn serialize_stub_as_v3() {
let mut signatures = BTreeMap::new();
@ -127,6 +129,7 @@ fn serialize_stub_as_v3() {
assert_eq!(to_json_value(&pdu_stub).unwrap(), json);
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn deserialize_stub_as_v1() {
let json = json!({
@ -184,6 +187,7 @@ fn deserialize_stub_as_v1() {
}
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn deserialize_stub_as_v3() {
let json = json!({
@ -227,6 +231,7 @@ fn deserialize_stub_as_v3() {
}
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn serialize_pdu_as_v1() {
let mut signatures = BTreeMap::new();
@ -294,6 +299,7 @@ fn serialize_pdu_as_v1() {
assert_eq!(to_json_value(&pdu).unwrap(), json);
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn serialize_pdu_as_v3() {
let mut signatures = BTreeMap::new();
@ -349,6 +355,7 @@ fn serialize_pdu_as_v3() {
assert_eq!(to_json_value(&pdu_stub).unwrap(), json);
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn test_deserialize_pdu_as_v1() {
let json = json!({
@ -408,6 +415,7 @@ fn test_deserialize_pdu_as_v1() {
}
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn deserialize_pdu_as_v3() {
let json = json!({
@ -452,6 +460,7 @@ fn deserialize_pdu_as_v3() {
}
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn convert_v1_stub_to_pdu() {
let mut signatures = BTreeMap::new();
@ -528,6 +537,7 @@ fn convert_v1_stub_to_pdu() {
);
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn convert_v3_stub_to_pdu() {
let mut signatures = BTreeMap::new();

View File

@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RoomState {
#[cfg(not(feature = "unstable-pre-spec"))]
/// The resident server's DNS name.
pub origin: String,

View File

@ -67,6 +67,7 @@ where
}
}
#[cfg(not(feature = "unstable-pre-spec"))]
#[cfg(test)]
mod tests {
use matches::assert_matches;

View File

@ -22,7 +22,7 @@ unstable-exhaustive-types = [
"ruma-federation-api/unstable-exhaustive-types",
"ruma-common/unstable-exhaustive-types",
]
unstable-pre-spec = ["ruma-client-api/unstable-pre-spec"]
unstable-pre-spec = ["ruma-client-api/unstable-pre-spec", "ruma-events/unstable-pre-spec"]
unstable-synapse-quirks = ["ruma-client-api/unstable-synapse-quirks"]
appservice-api = ["ruma-api", "ruma-appservice-api", "ruma-events"]