improvement: save state for send_join pdu
parent
e305889b72
commit
e50f2864de
|
@ -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(
|
||||||
&[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 @@ impl Rooms {
|
||||||
// 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,
|
||||||
|
|
Loading…
Reference in New Issue