Skip to content

Commit

Permalink
Remove origin field from transactions and pdus
Browse files Browse the repository at this point in the history
  • Loading branch information
timokoesters committed Sep 8, 2020
1 parent c3a0740 commit 9f4c720
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ruma-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ unstable-exhaustive-types = []
[[bench]]
name = "event_deserialize"
harness = false

[features]
unstable-pre-spec = []
6 changes: 6 additions & 0 deletions ruma-events/src/pdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,
Expand All @@ -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,

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions ruma-events/tests/pdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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!({
Expand Down Expand Up @@ -184,6 +187,7 @@ fn deserialize_stub_as_v1() {
}
}

#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn deserialize_stub_as_v3() {
let json = json!({
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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!({
Expand Down Expand Up @@ -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!({
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions ruma-federation-api/src/membership/create_join_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion ruma-federation-api/src/serde/room_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl<'de> Visitor<'de> for RoomStateVisitor {
}
}

#[cfg(not(feature = "unstable-pre-spec"))]
#[cfg(test)]
mod tests {
use matches::assert_matches;
Expand Down Expand Up @@ -142,7 +143,6 @@ mod tests {
RoomState { origin, auth_chain, state }
if origin == ""
&& auth_chain.is_empty()
&& state.is_empty()
);
}
}

0 comments on commit 9f4c720

Please sign in to comment.