Fix additional cases for room_id.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -612,14 +612,25 @@ pub(super) async fn force_set_room_state_from_server(
|
|||||||
.server_keys
|
.server_keys
|
||||||
.validate_and_add_event_id(pdu, &room_version)
|
.validate_and_add_event_id(pdu, &room_version)
|
||||||
}) {
|
}) {
|
||||||
let Ok((event_id, value)) = result.await else {
|
let Ok((event_id, mut value)) = result.await else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let pdu = PduEvent::from_id_val(&event_id, value.clone()).map_err(|e| {
|
let invalid_pdu_err = |e| {
|
||||||
debug_error!("Invalid PDU in fetching remote room state PDUs response: {value:#?}");
|
debug_error!("Invalid PDU in fetching remote room state PDUs response: {value:#?}");
|
||||||
err!(BadServerResponse(debug_error!("Invalid PDU in send_join response: {e:?}")))
|
err!(BadServerResponse(debug_error!("Invalid PDU in send_join response: {e:?}")))
|
||||||
})?;
|
};
|
||||||
|
|
||||||
|
let pdu = if value["type"] == "m.room.create" {
|
||||||
|
PduEvent::from_rid_val(&room_id, &event_id, value.clone()).map_err(invalid_pdu_err)?
|
||||||
|
} else {
|
||||||
|
PduEvent::from_id_val(&event_id, value.clone()).map_err(invalid_pdu_err)?
|
||||||
|
};
|
||||||
|
|
||||||
|
if !value.contains_key("room_id") {
|
||||||
|
let room_id = CanonicalJsonValue::String(room_id.as_str().into());
|
||||||
|
value.insert("room_id".into(), room_id);
|
||||||
|
}
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
|
|||||||
@@ -367,8 +367,13 @@ pub async fn join_remote(
|
|||||||
.validate_and_add_event_id_no_fetch(pdu, &room_version_id)
|
.validate_and_add_event_id_no_fetch(pdu, &room_version_id)
|
||||||
})
|
})
|
||||||
.ready_filter_map(Result::ok)
|
.ready_filter_map(Result::ok)
|
||||||
.fold(HashMap::new(), async |mut state, (event_id, value)| {
|
.fold(HashMap::new(), async |mut state, (event_id, mut value)| {
|
||||||
let pdu = if value["type"] == "m.room.create" {
|
let pdu = if value["type"] == "m.room.create" {
|
||||||
|
if !value.contains_key("room_id") {
|
||||||
|
let room_id = CanonicalJsonValue::String(room_id.as_str().into());
|
||||||
|
value.insert("room_id".into(), room_id);
|
||||||
|
}
|
||||||
|
|
||||||
PduEvent::from_rid_val(room_id, &event_id, value.clone())
|
PduEvent::from_rid_val(room_id, &event_id, value.clone())
|
||||||
} else {
|
} else {
|
||||||
PduEvent::from_id_val(&event_id, value.clone())
|
PduEvent::from_id_val(&event_id, value.clone())
|
||||||
@@ -415,7 +420,12 @@ pub async fn join_remote(
|
|||||||
.validate_and_add_event_id_no_fetch(pdu, &room_version_id)
|
.validate_and_add_event_id_no_fetch(pdu, &room_version_id)
|
||||||
})
|
})
|
||||||
.ready_filter_map(Result::ok)
|
.ready_filter_map(Result::ok)
|
||||||
.ready_for_each(|(event_id, value)| {
|
.ready_for_each(|(event_id, mut value)| {
|
||||||
|
if !value.contains_key("room_id") {
|
||||||
|
let room_id = CanonicalJsonValue::String(room_id.as_str().into());
|
||||||
|
value.insert("room_id".into(), room_id);
|
||||||
|
}
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.add_pdu_outlier(&event_id, &value);
|
.add_pdu_outlier(&event_id, &value);
|
||||||
|
|||||||
Reference in New Issue
Block a user