improvement: refactor state res and fix a few bugs in the process
This commit is contained in:
parent
16eed1d8c2
commit
c213769d9f
8 changed files with 651 additions and 833 deletions
|
@ -21,11 +21,7 @@ use ruma::{
|
|||
serde::{to_canonical_value, CanonicalJsonObject, Raw},
|
||||
EventId, RoomId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
convert::TryFrom,
|
||||
sync::Arc,
|
||||
};
|
||||
use std::{collections::BTreeMap, convert::TryFrom, sync::Arc};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
use rocket::{get, post};
|
||||
|
@ -573,7 +569,7 @@ async fn join_room_by_id_helper(
|
|||
let pdu = PduEvent::from_id_val(&event_id, join_event.clone())
|
||||
.map_err(|_| Error::BadServerResponse("Invalid PDU in send_join response."))?;
|
||||
|
||||
let mut state = HashMap::new();
|
||||
let mut state = BTreeMap::new();
|
||||
|
||||
for pdu in send_join_response
|
||||
.room_state
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::State;
|
||||
use crate::{ConduitResult, Database, Error, Ruma};
|
||||
use log::error;
|
||||
use ruma::{
|
||||
api::client::r0::sync::sync_events,
|
||||
events::{room::member::MembershipState, AnySyncEphemeralRoomEvent, EventType},
|
||||
|
@ -505,7 +506,10 @@ pub async fn sync_events_route(
|
|||
db.rooms
|
||||
.pdu_shortstatehash(&pdu.1.event_id)
|
||||
.ok()?
|
||||
.ok_or_else(|| Error::bad_database("Pdu in db doesn't have a state hash."))
|
||||
.ok_or_else(|| {
|
||||
error!("{:?}", pdu.1);
|
||||
Error::bad_database("Pdu in db doesn't have a state hash.")
|
||||
})
|
||||
.ok()
|
||||
})
|
||||
.and_then(|shortstatehash| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue