only remove event_id field in room v1 and v2

no this doesnt make those rooms work,
just a why not thing

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-24 21:07:04 -04:00 committed by June
parent 0863bec098
commit 4be37fbe8d
5 changed files with 70 additions and 15 deletions

View file

@ -18,7 +18,7 @@ use serde_json::{
};
use tracing::warn;
use crate::Error;
use crate::{services, Error};
/// Content hashes of a PDU.
#[derive(Clone, Debug, Deserialize, Serialize)]
@ -281,7 +281,21 @@ impl PduEvent {
unsigned.remove("transaction_id");
}
pdu_json.remove("event_id");
if let Some(room_id) = pdu_json.get("room_id").and_then(|val| RoomId::parse(val.as_str()?).ok()) {
if let Ok(room_version_id) = services().rooms.state.get_room_version(&room_id) {
// room v3 and above removed the "event_id" field from remote PDU format
match room_version_id {
RoomVersionId::V1 | RoomVersionId::V2 => {},
_ => {
pdu_json.remove("event_id");
},
};
} else {
pdu_json.remove("event_id");
}
} else {
pdu_json.remove("event_id");
}
// TODO: another option would be to convert it to a canonical string to validate
// size and return a Result<Raw<...>>

View file

@ -666,7 +666,13 @@ impl Service {
Error::bad_database("Failed to convert PDU to canonical JSON.")
})?;
pdu_json.remove("event_id");
// room v3 and above removed the "event_id" field from remote PDU format
match room_version_id {
RoomVersionId::V1 | RoomVersionId::V2 => {},
_ => {
pdu_json.remove("event_id");
},
};
// Add origin because synapse likes that (and it's required in the spec)
pdu_json.insert(