Skip to content
Snippets Groups Projects
Unverified Commit e50f2864 authored by Timo Kösters's avatar Timo Kösters
Browse files

improvement: save state for send_join pdu

parent e305889b
No related branches found
No related tags found
No related merge requests found
...@@ -650,6 +650,10 @@ async fn join_room_by_id_helper( ...@@ -650,6 +650,10 @@ async fn join_room_by_id_helper(
db.rooms.add_pdu_outlier(&pdu)?; db.rooms.add_pdu_outlier(&pdu)?;
} }
// We append to state before appending the pdu, so we don't have a moment in time with the
// pdu without it's state. This is okay because append_pdu can't fail.
let statehashid = db.rooms.append_to_state(&pdu, &db.globals)?;
db.rooms.append_pdu( db.rooms.append_pdu(
&pdu, &pdu,
utils::to_canonical_object(&pdu).expect("Pdu is valid canonical object"), utils::to_canonical_object(&pdu).expect("Pdu is valid canonical object"),
...@@ -658,6 +662,10 @@ async fn join_room_by_id_helper( ...@@ -658,6 +662,10 @@ async fn join_room_by_id_helper(
&[pdu.event_id.clone()], &[pdu.event_id.clone()],
db, db,
)?; )?;
// We set the room state after inserting the pdu, so that we never have a moment in time
// where events in the current room state do not exist
db.rooms.set_room_state(&room_id, statehashid)?;
} else { } else {
let event = member::MemberEventContent { let event = member::MemberEventContent {
membership: member::MembershipState::Join, membership: member::MembershipState::Join,
......
...@@ -1115,7 +1115,6 @@ pub fn build_and_append_pdu( ...@@ -1115,7 +1115,6 @@ pub fn build_and_append_pdu(
// pdu without it's state. This is okay because append_pdu can't fail. // pdu without it's state. This is okay because append_pdu can't fail.
let statehashid = self.append_to_state(&pdu, &db.globals)?; let statehashid = self.append_to_state(&pdu, &db.globals)?;
// remove the
self.append_pdu( self.append_pdu(
&pdu, &pdu,
pdu_json, pdu_json,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment