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 Aug 12, 2020
1 parent 63758e8 commit c9eb6b4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 43 deletions.
14 changes: 0 additions & 14 deletions ruma-events/src/pdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ pub struct RoomV1Pdu {
/// The user id of the user who sent this event.
pub sender: UserId,

/// 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.
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
Expand Down Expand Up @@ -96,9 +93,6 @@ pub struct RoomV3Pdu {
/// The user id of the user who sent this event.
pub sender: UserId,

/// 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.
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
Expand Down Expand Up @@ -172,9 +166,6 @@ pub struct RoomV1PduStub {
/// The user id of the user who sent this event.
pub sender: UserId,

/// 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.
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
Expand Down Expand Up @@ -226,7 +217,6 @@ impl RoomV1PduStub {
event_id,
room_id,
sender: self.sender,
origin: self.origin,
origin_server_ts: self.origin_server_ts,
kind: self.kind,
content: self.content,
Expand All @@ -248,9 +238,6 @@ pub struct RoomV3PduStub {
/// The user id of the user who sent this event.
pub sender: UserId,

/// 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.
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
Expand Down Expand Up @@ -301,7 +288,6 @@ impl RoomV3PduStub {
RoomV3Pdu {
room_id,
sender: self.sender,
origin: self.origin,
origin_server_ts: self.origin_server_ts,
kind: self.kind,
content: self.content,
Expand Down
18 changes: 0 additions & 18 deletions ruma-events/tests/pdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fn serialize_stub_as_v1() {

let v1_stub = RoomV1PduStub {
sender: user_id!("@sender:example.com"),
origin: "matrix.org".into(),
origin_server_ts: SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658),
kind: EventType::RoomPowerLevels,
content: json!({"testing": 123}),
Expand All @@ -47,7 +46,6 @@ fn serialize_stub_as_v1() {
let pdu_stub = PduStub::RoomV1PduStub(v1_stub);
let json = json!({
"sender": "@sender:example.com",
"origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658 as usize,
"type": "m.room.power_levels",
"content": {
Expand Down Expand Up @@ -86,7 +84,6 @@ fn serialize_stub_as_v3() {

let v3_stub = RoomV3PduStub {
sender: user_id!("@sender:example.com"),
origin: "matrix.org".into(),
origin_server_ts: SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658),
kind: EventType::RoomPowerLevels,
content: json!({"testing": 123}),
Expand All @@ -102,7 +99,6 @@ fn serialize_stub_as_v3() {
let pdu_stub = PduStub::RoomV3PduStub(v3_stub);
let json = json!({
"sender": "@sender:example.com",
"origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658 as usize,
"type": "m.room.power_levels",
"content": {
Expand Down Expand Up @@ -143,7 +139,6 @@ fn deserialize_stub_as_v1() {
"hashes": {
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
},
"origin": "matrix.org",
"origin_server_ts": 1_234_567_890,
"prev_events": [
[
Expand Down Expand Up @@ -195,7 +190,6 @@ fn deserialize_stub_as_v3() {
"hashes": {
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
},
"origin": "matrix.org",
"origin_server_ts": 1_234_567_890,
"prev_events": [
"$abc123:matrix.org"
Expand Down Expand Up @@ -239,7 +233,6 @@ fn serialize_pdu_as_v1() {
room_id: room_id!("!n8f893n9:example.com"),
event_id: event_id!("$somejoinevent:matrix.org"),
sender: user_id!("@sender:example.com"),
origin: "matrix.org".into(),
origin_server_ts: SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658),
kind: EventType::RoomPowerLevels,
content: json!({"testing": 123}),
Expand All @@ -263,7 +256,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 as usize,
"type": "m.room.power_levels",
"content": {
Expand Down Expand Up @@ -303,7 +295,6 @@ fn serialize_pdu_as_v3() {
let v3_pdu = RoomV3Pdu {
room_id: room_id!("!n8f893n9:example.com"),
sender: user_id!("@sender:example.com"),
origin: "matrix.org".into(),
origin_server_ts: SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658),
kind: EventType::RoomPowerLevels,
content: json!({"testing": 123}),
Expand All @@ -320,7 +311,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 as usize,
"type": "m.room.power_levels",
"content": {
Expand Down Expand Up @@ -363,7 +353,6 @@ fn test_deserialize_pdu_as_v1() {
"hashes": {
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
},
"origin": "matrix.org",
"origin_server_ts": 1_234_567_890,
"prev_events": [
[
Expand Down Expand Up @@ -416,7 +405,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 Expand Up @@ -458,7 +446,6 @@ fn convert_v1_stub_to_pdu() {

let v1_stub = RoomV1PduStub {
sender: user_id!("@sender:example.com"),
origin: "matrix.org".into(),
origin_server_ts: SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658),
kind: EventType::RoomPowerLevels,
content: json!({"testing": 123}),
Expand Down Expand Up @@ -487,7 +474,6 @@ fn convert_v1_stub_to_pdu() {
room_id,
event_id,
sender,
origin,
origin_server_ts,
kind,
content,
Expand All @@ -502,7 +488,6 @@ fn convert_v1_stub_to_pdu() {
} if room_id == room_id!("!n8f893n9:example.com")
&& event_id == event_id!("$somejoinevent:matrix.org")
&& sender == user_id!("@sender:example.com")
&& origin == "matrix.org"
&& origin_server_ts == SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658)
&& kind == EventType::RoomPowerLevels
&& content == json!({"testing": 123})
Expand Down Expand Up @@ -533,7 +518,6 @@ fn convert_v3_stub_to_pdu() {

let v3_stub = RoomV3PduStub {
sender: user_id!("@sender:example.com"),
origin: "matrix.org".into(),
origin_server_ts: SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658),
kind: EventType::RoomPowerLevels,
content: json!({"testing": 123}),
Expand All @@ -552,7 +536,6 @@ fn convert_v3_stub_to_pdu() {
RoomV3Pdu {
room_id,
sender,
origin,
origin_server_ts,
kind,
content,
Expand All @@ -566,7 +549,6 @@ fn convert_v3_stub_to_pdu() {
signatures,
} if room_id == room_id!("!n8f893n9:example.com")
&& sender == user_id!("@sender:example.com")
&& origin == "matrix.org"
&& origin_server_ts == SystemTime::UNIX_EPOCH + Duration::from_millis(1_592_050_773_658)
&& kind == EventType::RoomPowerLevels
&& content == json!({"testing": 123})
Expand Down
2 changes: 0 additions & 2 deletions ruma-federation-api/src/membership/create_join_event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use serde::{Deserialize, Serialize};
/// Full state of the room.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RoomState {
/// The resident server's DNS name.
pub origin: String,
/// The full set of authorization events that make up the state of the room,
/// and their authorization events, recursively.
pub auth_chain: Vec<Raw<Pdu>>,
Expand Down
14 changes: 5 additions & 9 deletions ruma-federation-api/src/serde/room_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ mod tests {
let response = json!([
200,
{
"origin": "example.com",
"auth_chain": [],
"state": []
}
Expand All @@ -79,17 +78,15 @@ mod tests {

assert_matches!(
parsed,
RoomState { origin, auth_chain, state }
if origin == "example.com"
&& auth_chain.is_empty()
RoomState { auth_chain, state }
if auth_chain.is_empty()
&& state.is_empty()
);
}

#[test]
fn test_serialize_response() {
let room_state =
RoomState { origin: "matrix.org".into(), auth_chain: Vec::new(), state: Vec::new() };
let room_state = RoomState { auth_chain: Vec::new(), state: Vec::new() };

let serialized = serialize(&room_state, serde_json::value::Serializer).unwrap();
let expected = to_json_value(&json!(
Expand Down Expand Up @@ -137,9 +134,8 @@ mod tests {
let json = json!([200, {"origin": "", "auth_chain": [], "state": []}, 200]);
assert_matches!(
deserialize(json).unwrap(),
RoomState { origin, auth_chain, state }
if origin == ""
&& auth_chain.is_empty()
RoomState { auth_chain, state }
if auth_chain.is_empty()
&& state.is_empty()
);
}
Expand Down

0 comments on commit c9eb6b4

Please sign in to comment.