Skip to content

Commit

Permalink
Remove origin field from PDUs
Browse files Browse the repository at this point in the history
It has been removed from the spec, for details see
matrix-org/matrix-spec#998
  • Loading branch information
jplatte committed Mar 29, 2022
1 parent 77e44d6 commit cac285e
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 26 deletions.
8 changes: 0 additions & 8 deletions crates/ruma-common/src/events/pdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ pub struct RoomV1Pdu {
/// The user id of the user who sent this event.
pub sender: Box<UserId>,

#[cfg(not(feature = "unstable-pre-spec"))]
/// The `server_name` of the homeserver that created this event.
pub origin: String,

/// Timestamp (milliseconds since the UNIX epoch) on originating homeserver
/// of when this event was created.
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
Expand Down Expand Up @@ -101,10 +97,6 @@ pub struct RoomV3Pdu {
/// The user id of the user who sent this event.
pub sender: Box<UserId>,

#[cfg(not(feature = "unstable-pre-spec"))]
/// The `server_name` of the homeserver that created this event.
pub origin: String,

/// Timestamp (milliseconds since the UNIX epoch) on originating homeserver
/// of when this event was created.
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
Expand Down
9 changes: 1 addition & 8 deletions crates/ruma-common/tests/events/pdu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(all(feature = "unstable-pdu", not(feature = "unstable-pre-spec")))]
#![cfg(all(feature = "unstable-pdu"))]

use std::{collections::BTreeMap, convert::TryInto};

Expand Down Expand Up @@ -32,7 +32,6 @@ fn serialize_pdu_as_v1() {
room_id: room_id!("!n8f893n9:example.com").to_owned(),
event_id: event_id!("$somejoinevent:matrix.org").to_owned(),
sender: user_id!("@sender:example.com").to_owned(),
origin: "matrix.org".into(),
origin_server_ts: MilliSecondsSinceUnixEpoch(1_592_050_773_658_u64.try_into().unwrap()),
kind: RoomEventType::RoomPowerLevels,
content: to_raw_json_value(&json!({ "testing": 123 })).unwrap(),
Expand All @@ -56,7 +55,6 @@ fn serialize_pdu_as_v1() {
"room_id": "!n8f893n9:example.com",
"event_id": "$somejoinevent:matrix.org",
"sender": "@sender:example.com",
"origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658_u64,
"type": "m.room.power_levels",
"content": {
Expand Down Expand Up @@ -98,7 +96,6 @@ fn serialize_pdu_as_v3() {
let v3_pdu = RoomV3Pdu {
room_id: room_id!("!n8f893n9:example.com").to_owned(),
sender: user_id!("@sender:example.com").to_owned(),
origin: "matrix.org".into(),
origin_server_ts: MilliSecondsSinceUnixEpoch(1_592_050_773_658_u64.try_into().unwrap()),
kind: RoomEventType::RoomPowerLevels,
content: to_raw_json_value(&json!({ "testing": 123 })).unwrap(),
Expand All @@ -115,7 +112,6 @@ fn serialize_pdu_as_v3() {
let json = json!({
"room_id": "!n8f893n9:example.com",
"sender": "@sender:example.com",
"origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658_u64,
"type": "m.room.power_levels",
"content": {
Expand Down Expand Up @@ -158,7 +154,6 @@ fn deserialize_pdu_as_v1() {
"hashes": {
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
},
"origin": "matrix.org",
"origin_server_ts": 1_234_567_890,
"prev_events": [
[
Expand Down Expand Up @@ -198,7 +193,6 @@ fn deserialize_pdu_as_v1() {
}
}

#[cfg(not(feature = "unstable-pre-spec"))]
#[test]
fn deserialize_pdu_as_v3() {
let json = json!({
Expand All @@ -213,7 +207,6 @@ fn deserialize_pdu_as_v3() {
"hashes": {
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
},
"origin": "matrix.org",
"origin_server_ts": 1_234_567_890,
"prev_events": [
"$abc123:matrix.org"
Expand Down
3 changes: 0 additions & 3 deletions crates/ruma-state-res/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ all-features = true
compat = []
unstable-exhaustive-types = []

# Private, only used in test / benchmarking code
__ci = ["ruma-common/unstable-pre-spec"]

[dependencies]
itertools = "0.10.0"
js_int = "0.2.0"
Expand Down
2 changes: 0 additions & 2 deletions crates/ruma-state-res/benches/state_res_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,6 @@ where
content,
redacts: None,
unsigned: btreemap! {},
#[cfg(not(feature = "__ci"))]
origin: "foo".into(),
auth_events,
prev_events,
depth: uint!(0),
Expand Down
4 changes: 0 additions & 4 deletions crates/ruma-state-res/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ pub fn to_init_pdu_event(
content,
redacts: None,
unsigned: BTreeMap::new(),
#[cfg(not(feature = "__ci"))]
origin: "foo".into(),
auth_events: vec![],
prev_events: vec![],
depth: uint!(0),
Expand Down Expand Up @@ -443,8 +441,6 @@ where
content,
redacts: None,
unsigned: BTreeMap::new(),
#[cfg(not(feature = "__ci"))]
origin: "foo".into(),
auth_events,
prev_events,
depth: uint!(0),
Expand Down
1 change: 0 additions & 1 deletion crates/ruma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ __ci = [
"unstable-msc3554",
"unstable-msc3618",
"unstable-msc3723",
"ruma-state-res/__ci",
]

[dependencies]
Expand Down

0 comments on commit cac285e

Please sign in to comment.